delete pics to save space
This commit is contained in:
7
history_source/ccf 入门篇/U4/4.1.1.cpp
Normal file
7
history_source/ccf 入门篇/U4/4.1.1.cpp
Normal file
@ -0,0 +1,7 @@
|
||||
#include<iostream>
|
||||
using namespace std;
|
||||
int main()
|
||||
{
|
||||
cout<<"0\n\n25\n\n1#\n2$\n3\n4\n5\n\n25:28\n67:70";
|
||||
while(true);
|
||||
}
|
25
history_source/ccf 入门篇/U4/4.1.2.cpp
Normal file
25
history_source/ccf 入门篇/U4/4.1.2.cpp
Normal file
@ -0,0 +1,25 @@
|
||||
#include<iostream>
|
||||
using namespace std;
|
||||
int main()
|
||||
{
|
||||
long double s=1;
|
||||
for(int i=2;i<=100;i++)
|
||||
{
|
||||
if(i%2==1) s=s-i;
|
||||
else s=s+i;
|
||||
}
|
||||
cout<<int(s)<<endl;
|
||||
s=0;
|
||||
for(int i=1;i<=10;i++)
|
||||
{
|
||||
s=s+i*(11-i);
|
||||
}
|
||||
cout<<int(s)<<endl;
|
||||
s=0;
|
||||
for(int i=1;i<=100;i++)
|
||||
{
|
||||
s=s+1.0/i;
|
||||
}
|
||||
cout<<s;
|
||||
while(true);
|
||||
}
|
15
history_source/ccf 入门篇/U4/4.1.3.cpp
Normal file
15
history_source/ccf 入门篇/U4/4.1.3.cpp
Normal file
@ -0,0 +1,15 @@
|
||||
#include<iostream>
|
||||
using namespace std;
|
||||
int main()
|
||||
{
|
||||
float n,s,p;
|
||||
cin>>n;
|
||||
for(int i=0;i<n;i++)
|
||||
{
|
||||
cin>>p;
|
||||
s=s+p;
|
||||
}
|
||||
p=s/n;
|
||||
cout<<int(p*100.0)/100.0;
|
||||
while(true);
|
||||
}
|
20
history_source/ccf 入门篇/U4/4.1.4.cpp
Normal file
20
history_source/ccf 入门篇/U4/4.1.4.cpp
Normal file
@ -0,0 +1,20 @@
|
||||
#include<iostream>
|
||||
using namespace std;
|
||||
int main()
|
||||
{
|
||||
while(true)
|
||||
{
|
||||
|
||||
int n,b,s,a;
|
||||
cin>>n;
|
||||
cin>>s;
|
||||
b=s+1;
|
||||
for(int i=0;i<n-1;i++)
|
||||
{
|
||||
cin>>a;
|
||||
if(a>b) b=a;
|
||||
else if(a<s) s=a;
|
||||
}
|
||||
cout<<b-s<<endl<<endl;
|
||||
}
|
||||
}
|
15
history_source/ccf 入门篇/U4/4.1.5.cpp
Normal file
15
history_source/ccf 入门篇/U4/4.1.5.cpp
Normal file
@ -0,0 +1,15 @@
|
||||
#include<iostream>
|
||||
using namespace std;
|
||||
int main()
|
||||
{
|
||||
unsigned long long s;
|
||||
s=1;
|
||||
for(int i=1;i<64;i++)
|
||||
{
|
||||
s=s+s*2;
|
||||
}
|
||||
long double t;
|
||||
t=s/142000000;
|
||||
cout<<t;
|
||||
while(true);
|
||||
}
|
18
history_source/ccf 入门篇/U4/4.1.6.cpp
Normal file
18
history_source/ccf 入门篇/U4/4.1.6.cpp
Normal file
@ -0,0 +1,18 @@
|
||||
#include<iostream>
|
||||
using namespace std;
|
||||
int main()
|
||||
{
|
||||
int n;
|
||||
int s;
|
||||
while(true)
|
||||
{
|
||||
cin>>n;
|
||||
s=0;
|
||||
for(int i=1;i*i<=n;i++)
|
||||
{
|
||||
if(n%i==0) s=s+2;
|
||||
if(i*i==n) s=s-1;
|
||||
}
|
||||
cout<<s<<endl;
|
||||
}
|
||||
}
|
21
history_source/ccf 入门篇/U4/4.1.7.cpp
Normal file
21
history_source/ccf 入门篇/U4/4.1.7.cpp
Normal file
@ -0,0 +1,21 @@
|
||||
#include<iostream>
|
||||
using namespace std;
|
||||
int main()
|
||||
{
|
||||
int n,a,b,c,a1,b1,c1;
|
||||
while(true)
|
||||
{
|
||||
a=0;
|
||||
b=0;
|
||||
c=0;
|
||||
cin>>n;
|
||||
for(int i=0;i<n;i++)
|
||||
{
|
||||
cin>>a1>>b1>>c1;
|
||||
a+=a1;
|
||||
b+=b1;
|
||||
c+=c1;
|
||||
}
|
||||
cout<<a<<" "<<b<<" "<<c<<" "<<a+b+c<<endl<<endl;
|
||||
}
|
||||
}
|
20
history_source/ccf 入门篇/U4/4.1.8.cpp
Normal file
20
history_source/ccf 入门篇/U4/4.1.8.cpp
Normal file
@ -0,0 +1,20 @@
|
||||
#include<iostream>
|
||||
using namespace std;
|
||||
int main()
|
||||
{
|
||||
int a,b,s,f;
|
||||
while(true)
|
||||
{
|
||||
cin>>s;
|
||||
b=s+1;
|
||||
a=a+s;
|
||||
for(int i=0;i<9;i++)
|
||||
{
|
||||
cin>>f;
|
||||
if(f>b) b=f;
|
||||
if(f<s) s=f;
|
||||
a=a+f;
|
||||
}
|
||||
cout<<(a-b-s)/8.0<<endl<<endl;
|
||||
}
|
||||
}
|
17
history_source/ccf 入门篇/U4/4.1.9.cpp
Normal file
17
history_source/ccf 入门篇/U4/4.1.9.cpp
Normal file
@ -0,0 +1,17 @@
|
||||
#include<iostream>
|
||||
using namespace std;
|
||||
int main()
|
||||
{
|
||||
int m,t,f;
|
||||
while(true)
|
||||
{
|
||||
m=0;
|
||||
cin>>t;
|
||||
for(int i=0;i<10;i++)
|
||||
{
|
||||
cin>>f;
|
||||
if(t+30>=f) m++;
|
||||
}
|
||||
cout<<m<<endl<<endl;
|
||||
}
|
||||
}
|
7
history_source/ccf 入门篇/U4/4.2.1.cpp
Normal file
7
history_source/ccf 入门篇/U4/4.2.1.cpp
Normal file
@ -0,0 +1,7 @@
|
||||
#include<iostream>
|
||||
using namespace std;
|
||||
int main()
|
||||
{
|
||||
cout<<"0 4201 987654321\n\n000 \n\n50 1 1";
|
||||
while(true);
|
||||
}
|
26
history_source/ccf 入门篇/U4/4.2.2.cpp
Normal file
26
history_source/ccf 入门篇/U4/4.2.2.cpp
Normal file
@ -0,0 +1,26 @@
|
||||
#include<iostream>
|
||||
#include<cmath>
|
||||
using namespace std;
|
||||
int main()
|
||||
{
|
||||
int f,i,s,a;
|
||||
while(true)
|
||||
{
|
||||
i=0;
|
||||
s=0;
|
||||
cin>>f;
|
||||
while(true)
|
||||
{
|
||||
a=f;
|
||||
a=a/pow(10,i);
|
||||
if(a==0) break;
|
||||
else
|
||||
{
|
||||
a=a%10;
|
||||
s=s+a;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
cout<<s<<endl;
|
||||
}
|
||||
}
|
17
history_source/ccf 入门篇/U4/4.2.3.cpp
Normal file
17
history_source/ccf 入门篇/U4/4.2.3.cpp
Normal file
@ -0,0 +1,17 @@
|
||||
#include<iostream>
|
||||
#include<cmath>
|
||||
using namespace std;
|
||||
int main()
|
||||
{
|
||||
int m,n,b,i;
|
||||
while(true)
|
||||
{
|
||||
cin>>m>>n;
|
||||
b=(m>n)?m:n;
|
||||
for(i=2;i<=b;i++)
|
||||
{
|
||||
if(m%i==0&&n%i==0) {cout<<"No"<<endl;break;}
|
||||
}
|
||||
if(!(m%i==0&&n%i==0)) cout<<"Yes"<<endl;
|
||||
}
|
||||
}
|
20
history_source/ccf 入门篇/U4/4.2.4.cpp
Normal file
20
history_source/ccf 入门篇/U4/4.2.4.cpp
Normal file
@ -0,0 +1,20 @@
|
||||
#include<iostream>
|
||||
#include<string>
|
||||
#include<sstream>
|
||||
using namespace std;
|
||||
int main()
|
||||
{
|
||||
string j;
|
||||
stringstream num;
|
||||
int s,b,n;
|
||||
while(true)
|
||||
{
|
||||
cin>>s>>b;
|
||||
n=0;
|
||||
num.flush();
|
||||
for(int i=0;i<b-s+1;i++) num<<s+i;
|
||||
num>>j;
|
||||
for(int i=0;i<j.size();i++) if(j[i]=='2') n++;
|
||||
cout<<n<<endl;
|
||||
}
|
||||
}
|
48
history_source/ccf 入门篇/U4/4.2.5.cpp
Normal file
48
history_source/ccf 入门篇/U4/4.2.5.cpp
Normal file
@ -0,0 +1,48 @@
|
||||
#include<iostream>
|
||||
#include<cmath>
|
||||
using namespace std;
|
||||
int k;
|
||||
long long n;
|
||||
long double f(long long n)
|
||||
{
|
||||
long double s=0;
|
||||
for(int i=1;i<=n;i++)
|
||||
{
|
||||
s=s+1.0/i;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
int main()
|
||||
{
|
||||
while(true)
|
||||
{
|
||||
cin>>k;
|
||||
if(k>=10) n=pow(k,4);
|
||||
else{
|
||||
if(k>=6) n=pow(k,3);
|
||||
else n=k*k;
|
||||
}
|
||||
if(k<12){
|
||||
while(f(n)<=k)n+=3;
|
||||
if(f(n-1)>k)
|
||||
{if(f(n-2)>k) cout<<n-2<<endl;
|
||||
else cout<<n-1<<endl;}
|
||||
else cout<<n<<endl;}
|
||||
else {
|
||||
if(k>=14) n=pow(k,5);
|
||||
if(k>=15) while(f(n)<=k) n+=4096;
|
||||
else while(f(n)<=k) n+=2048;
|
||||
if(f(n-2048)>k) n-=2048;
|
||||
if(f(n-1024)>k) n-=1024;
|
||||
if(f(n-512)>k) n-=512;
|
||||
if(f(n-256)>k) n-=256;
|
||||
if(f(n-128)>k) n-=128;
|
||||
if(f(n-64)>k) n-=64;
|
||||
if(f(n-32)>k) n-=32;
|
||||
if(f(n-16)>k) n-=16;
|
||||
while(f(n)>k) n--;
|
||||
n++;
|
||||
cout<<n<<endl;
|
||||
}
|
||||
}
|
||||
}
|
21
history_source/ccf 入门篇/U4/4.2.6.cpp
Normal file
21
history_source/ccf 入门篇/U4/4.2.6.cpp
Normal file
@ -0,0 +1,21 @@
|
||||
#include<iostream>
|
||||
#include<cmath>
|
||||
#include<string>
|
||||
using namespace std;
|
||||
int main()
|
||||
{
|
||||
string a;
|
||||
char f;
|
||||
while(true)
|
||||
{
|
||||
cin>>a;
|
||||
for(int i=0;i<a.size();i++)
|
||||
{
|
||||
f=a[i];
|
||||
if(f>='A'&&f<='Z') f=(f-'A'+3)%26+'A';
|
||||
if(f>='a'&&f<='z') f=(f-'a'+3)%26+'a';
|
||||
cout<<f;
|
||||
}
|
||||
cout<<endl<<endl;
|
||||
}
|
||||
}
|
7
history_source/ccf 入门篇/U4/4.3.1.cpp
Normal file
7
history_source/ccf 入门篇/U4/4.3.1.cpp
Normal file
@ -0,0 +1,7 @@
|
||||
#include<iostream>
|
||||
using namespace std;
|
||||
int main()
|
||||
{
|
||||
cout<<"001 0\n\n50 1 0\n\n8";
|
||||
while(true);
|
||||
}
|
17
history_source/ccf 入门篇/U4/4.3.2.cpp
Normal file
17
history_source/ccf 入门篇/U4/4.3.2.cpp
Normal file
@ -0,0 +1,17 @@
|
||||
#include<iostream>
|
||||
#include<cmath>
|
||||
using namespace std;
|
||||
int main()
|
||||
{
|
||||
long double pi4=0;
|
||||
long long n=1,j=1;
|
||||
do
|
||||
{
|
||||
if(j%2==1) pi4=pi4+1.0/n;
|
||||
else pi4=pi4-1.0/n;
|
||||
n+=2;
|
||||
j++;
|
||||
}while(1.0/n>=0.000001);
|
||||
cout<<pi4*4.0;
|
||||
while(true);
|
||||
}
|
14
history_source/ccf 入门篇/U4/4.3.3.cpp
Normal file
14
history_source/ccf 入门篇/U4/4.3.3.cpp
Normal file
@ -0,0 +1,14 @@
|
||||
#include<iostream>
|
||||
#include<cmath>
|
||||
using namespace std;
|
||||
int main()
|
||||
{
|
||||
double l=200,s=0;
|
||||
do
|
||||
{
|
||||
s=s+l;
|
||||
l/=2;
|
||||
} while(l>=0.5);
|
||||
cout<<s;
|
||||
while(true);
|
||||
}
|
27
history_source/ccf 入门篇/U4/4.3.4.cpp
Normal file
27
history_source/ccf 入门篇/U4/4.3.4.cpp
Normal file
@ -0,0 +1,27 @@
|
||||
#include<iostream>
|
||||
#include<string>
|
||||
#include<sstream>
|
||||
#include<cmath>
|
||||
using namespace std;
|
||||
int main()
|
||||
{
|
||||
stringstream num;
|
||||
string j;
|
||||
int a,b;
|
||||
bool z,x;
|
||||
while(true)
|
||||
{
|
||||
cin>>a;
|
||||
z=0;
|
||||
if(a<0){z=1;a=abs(a);}
|
||||
b=0;
|
||||
do
|
||||
{
|
||||
b=b*10+a%10;
|
||||
a/=10;
|
||||
}while(a>0);
|
||||
a=b;
|
||||
if(z==1) a=0-a;
|
||||
cout<<a<<endl;
|
||||
}
|
||||
}
|
32
history_source/ccf 入门篇/U4/4.3.5.cpp
Normal file
32
history_source/ccf 入门篇/U4/4.3.5.cpp
Normal file
@ -0,0 +1,32 @@
|
||||
#include<cstdio>
|
||||
using namespace std;
|
||||
int main()
|
||||
{
|
||||
int x=1,y=1,n;
|
||||
scanf("%d",&n);
|
||||
bool f=1;
|
||||
for(int i=1;i<n;i++)
|
||||
{
|
||||
if(f)
|
||||
{
|
||||
if(y>1) y--,x++;
|
||||
else
|
||||
{
|
||||
f=0;
|
||||
x++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(x>1) x--,y++;
|
||||
else
|
||||
{
|
||||
f=1;
|
||||
y++;
|
||||
}
|
||||
}
|
||||
}
|
||||
printf("%d/%d\n",y,x);
|
||||
return 0;
|
||||
}
|
||||
|
18
history_source/ccf 入门篇/U4/4.3.6.cpp
Normal file
18
history_source/ccf 入门篇/U4/4.3.6.cpp
Normal file
@ -0,0 +1,18 @@
|
||||
#include<iostream>
|
||||
using namespace std;
|
||||
int main()
|
||||
{
|
||||
int n,a;
|
||||
while(true)
|
||||
{
|
||||
cin>>n;
|
||||
a=1;
|
||||
while(n!=1)
|
||||
{
|
||||
if(n%2==0) n/=2;
|
||||
else n=3*n+1;
|
||||
a++;
|
||||
}
|
||||
cout<<a<<endl;
|
||||
}
|
||||
}
|
18
history_source/ccf 入门篇/U4/4.4.2.cpp
Normal file
18
history_source/ccf 入门篇/U4/4.4.2.cpp
Normal file
@ -0,0 +1,18 @@
|
||||
#include<iostream>
|
||||
using namespace std;
|
||||
int main()
|
||||
{
|
||||
int n;
|
||||
while(true)
|
||||
{
|
||||
cin>>n;
|
||||
for(int i=0;i<n;i++)
|
||||
{
|
||||
for(int a=0;a<(n*2-1-i*2-1)/2;a++) cout<<" ";
|
||||
for(int a=0;a<i*2+1;a++) cout<<"*";
|
||||
for(int a=0;a<(n*2-1-i*2-1)/2;a++) cout<<" ";
|
||||
cout<<endl;
|
||||
}
|
||||
cout<<endl;
|
||||
}
|
||||
}
|
25
history_source/ccf 入门篇/U4/4.4.3.cpp
Normal file
25
history_source/ccf 入门篇/U4/4.4.3.cpp
Normal file
@ -0,0 +1,25 @@
|
||||
#include<iostream>
|
||||
using namespace std;
|
||||
int main()
|
||||
{
|
||||
int n;
|
||||
while(true)
|
||||
{
|
||||
cin>>n;
|
||||
for(int i=0;i<n;i++)
|
||||
{
|
||||
for(int a=0;a<(n*2-1-i*2-1)/2;a++) cout<<" ";
|
||||
for(int a=1;a<=i*2+1;a++) cout<<a;
|
||||
for(int a=0;a<(n*2-1-i*2-1)/2;a++) cout<<" ";
|
||||
cout<<endl;
|
||||
}
|
||||
for(int i=1;i<=n-1;i++)
|
||||
{
|
||||
for(int a=0;a<i;a++) cout<<" ";
|
||||
for(int a=1;a<=2*n-1-2*i;a++) cout<<a;
|
||||
for(int a=0;a<i;a++) cout<<" ";
|
||||
cout<<endl;
|
||||
}
|
||||
cout<<endl;
|
||||
}
|
||||
}
|
16
history_source/ccf 入门篇/U4/4.4.4.cpp
Normal file
16
history_source/ccf 入门篇/U4/4.4.4.cpp
Normal file
@ -0,0 +1,16 @@
|
||||
#include<iostream>
|
||||
using namespace std;
|
||||
int main()
|
||||
{
|
||||
int n;
|
||||
while(true)
|
||||
{
|
||||
cin>>n;
|
||||
for(int i=1;i<=n;i++)
|
||||
{
|
||||
for(int a=1;a<=i;a++) cout<<a<<"*"<<i<<"="<<a*i<<" ";
|
||||
cout<<endl;
|
||||
}
|
||||
cout<<endl;
|
||||
}
|
||||
}
|
19
history_source/ccf 入门篇/U4/4.4.5.cpp
Normal file
19
history_source/ccf 入门篇/U4/4.4.5.cpp
Normal file
@ -0,0 +1,19 @@
|
||||
#include<iostream>
|
||||
using namespace std;
|
||||
int main()
|
||||
{
|
||||
int n,s,r,w,a;
|
||||
while(true)
|
||||
{
|
||||
cin>>n;
|
||||
a=0;
|
||||
for(w=0;w<=n/50;w++)
|
||||
{
|
||||
for(r=0;r<=n/20;r++)
|
||||
{
|
||||
for(s=0;s<=100/10;s++) if(w*50+r*20+s*10==n) a++;
|
||||
}
|
||||
}
|
||||
cout<<a<<endl;
|
||||
}
|
||||
}
|
23
history_source/ccf 入门篇/U4/4.4.6.cpp
Normal file
23
history_source/ccf 入门篇/U4/4.4.6.cpp
Normal file
@ -0,0 +1,23 @@
|
||||
#include<iostream>
|
||||
using namespace std;
|
||||
int main()
|
||||
{
|
||||
int a,b;
|
||||
while(true)
|
||||
{
|
||||
cin>>a;
|
||||
do
|
||||
{
|
||||
b=0;
|
||||
do
|
||||
{
|
||||
b=b+a%10;
|
||||
a/=10;
|
||||
}
|
||||
while(a>0);
|
||||
a=b;
|
||||
}
|
||||
while(a/10>0);
|
||||
cout<<a;
|
||||
}
|
||||
}
|
26
history_source/ccf 入门篇/U4/4.4.7.cpp
Normal file
26
history_source/ccf 入门篇/U4/4.4.7.cpp
Normal file
@ -0,0 +1,26 @@
|
||||
#include<iostream>
|
||||
using namespace std;
|
||||
int zd(int a,int b)
|
||||
{
|
||||
int ans=1;
|
||||
for(int i=2;i<=(a<b?a:b);i++) if(a%i==0&&b%i==0) ans=i;
|
||||
return ans;
|
||||
}
|
||||
int zx(int a,int b)
|
||||
{
|
||||
return a*b/zd(a,b);
|
||||
}
|
||||
int main()
|
||||
{
|
||||
int answer,x,y,p,q;
|
||||
while(true)
|
||||
{
|
||||
answer=0;
|
||||
cin>>x>>y;
|
||||
for(p=x;p<=y;p++)
|
||||
{
|
||||
for(q=x;q<=y;q++) if(zd(p,q)==x&&zx(p,q)==y) answer++;
|
||||
}
|
||||
cout<<answer<<endl;
|
||||
}
|
||||
}
|
9
history_source/ccf 入门篇/U4/4.5.1.cpp
Normal file
9
history_source/ccf 入门篇/U4/4.5.1.cpp
Normal file
@ -0,0 +1,9 @@
|
||||
#include<iostream>
|
||||
using namespace std;
|
||||
int main()
|
||||
{
|
||||
cout<<"9\n28\n2047\n\n\n";
|
||||
cout<<"0\n1\n12\n\n\n";
|
||||
cout<<"9\n28\n2047";
|
||||
while(true);
|
||||
}
|
17
history_source/ccf 入门篇/U4/4.5.2.cpp
Normal file
17
history_source/ccf 入门篇/U4/4.5.2.cpp
Normal file
@ -0,0 +1,17 @@
|
||||
#include<iostream>
|
||||
using namespace std;
|
||||
int main()
|
||||
{
|
||||
int n;
|
||||
while(true)
|
||||
{
|
||||
cin>>n;
|
||||
do
|
||||
{
|
||||
cout<<"<EFBFBD><EFBFBD> "<<n/2<<"<EFBFBD><EFBFBD>"<<"<EFBFBD><EFBFBD> "<<n%2<<endl;
|
||||
n/=2;
|
||||
}
|
||||
while(n>0);
|
||||
cout<<endl;
|
||||
}
|
||||
}
|
17
history_source/ccf 入门篇/U4/4.5.3.cpp
Normal file
17
history_source/ccf 入门篇/U4/4.5.3.cpp
Normal file
@ -0,0 +1,17 @@
|
||||
#include<iostream>
|
||||
#include<cmath>
|
||||
using namespace std;
|
||||
int main()
|
||||
{
|
||||
long long a,b;
|
||||
while(true)
|
||||
{
|
||||
cin>>a>>b;
|
||||
a=a%10;
|
||||
for(int i=1;i<b;i++){
|
||||
a=a*a;
|
||||
a=a%10;
|
||||
}
|
||||
cout<<a<<endl;
|
||||
}
|
||||
}
|
15
history_source/ccf 入门篇/U4/4.5.4.cpp
Normal file
15
history_source/ccf 入门篇/U4/4.5.4.cpp
Normal file
@ -0,0 +1,15 @@
|
||||
#include<iostream>
|
||||
using namespace std;
|
||||
int main()
|
||||
{
|
||||
int j[13],a;
|
||||
while(true)
|
||||
{
|
||||
for(int i=0;i<13;i++) j[i]=0;
|
||||
for(int i=0;i<25;i++){
|
||||
cin>>a;
|
||||
j[a-1]=j[a-1]+1;
|
||||
}
|
||||
for(int i=0;i<13;i++) if(j[i]<2) cout<<i+1;
|
||||
}
|
||||
}
|
12
history_source/ccf 入门篇/U4/4.5.5.cpp
Normal file
12
history_source/ccf 入门篇/U4/4.5.5.cpp
Normal file
@ -0,0 +1,12 @@
|
||||
#include<iostream>
|
||||
#include<cmath>
|
||||
using namespace std;
|
||||
int main()
|
||||
{
|
||||
int n;
|
||||
while(true)
|
||||
{
|
||||
cin>>n;
|
||||
cout<<pow(2,n)<<endl<<"============="<<endl;
|
||||
}
|
||||
}
|
15
history_source/ccf 入门篇/U4/4.5.6.cpp
Normal file
15
history_source/ccf 入门篇/U4/4.5.6.cpp
Normal file
@ -0,0 +1,15 @@
|
||||
#include<iostream>
|
||||
#include<cmath>
|
||||
using namespace std;
|
||||
int main()
|
||||
{
|
||||
int n,m,k,x;
|
||||
long long a;
|
||||
while(true)
|
||||
{
|
||||
cin>>n>>m>>k>>x;
|
||||
a=pow(10,k);
|
||||
k=a%n;
|
||||
cout<<(m*k+x)%n<<endl;
|
||||
}
|
||||
}
|
52
history_source/ccf 入门篇/U4/4.6.1.cpp
Normal file
52
history_source/ccf 入门篇/U4/4.6.1.cpp
Normal file
@ -0,0 +1,52 @@
|
||||
#include<iostream>
|
||||
#include<cmath>
|
||||
using namespace std;
|
||||
int p;
|
||||
bool pan(int a,int b,int c,int d,int e,int f,int g,int h,int i)
|
||||
{
|
||||
if((a<f&&f<i)&&(b<d&&g<h&&c<e)&&(a+b+d+f==f+g+h+i==i+e+c+a==p)) return 1;
|
||||
else return 0;
|
||||
}
|
||||
int main()
|
||||
{
|
||||
int n;
|
||||
while(true)
|
||||
{
|
||||
cin>>p;
|
||||
n=0;
|
||||
for(int a=1;a<=9;a++)
|
||||
{
|
||||
for(int b=1;b<=9;b++)
|
||||
{
|
||||
if(b==a) continue;
|
||||
for(int c=1;c<=9;c++)
|
||||
{
|
||||
if(c==a||c==b) continue;
|
||||
for(int d=1;d<=9;d++)
|
||||
{
|
||||
if(d==a||d==b||d==c) continue;
|
||||
for(int e=1;e<=9;e++)
|
||||
{
|
||||
if(e==a||e==b||e==c||e==d) continue;
|
||||
for(int f=1;f<=9;f++)
|
||||
{
|
||||
if(f==a||f==b||f==c||f==d||f==e) continue;
|
||||
for(int g=1;g<=9;g++)
|
||||
{
|
||||
if(g==a||g==b||g==c||g==d||g==e||g==f) continue;
|
||||
for(int h=1;h<=9;h++)
|
||||
{
|
||||
if(h==a||h==b||h==c||h==d||h==e||h==f||h==g) continue;
|
||||
int i=45-a-b-c-d-e-f-g-h;
|
||||
if(pan(a,b,c,d,e,f,g,h,i)) n++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
cout<<n<<endl;
|
||||
}
|
||||
}
|
42
history_source/ccf 入门篇/U4/4.6.2.cpp
Normal file
42
history_source/ccf 入门篇/U4/4.6.2.cpp
Normal file
@ -0,0 +1,42 @@
|
||||
#include<iostream>
|
||||
#include<cmath>
|
||||
using namespace std;
|
||||
int n;
|
||||
void pai(int &x,int &y)
|
||||
{
|
||||
while(x>0&&y>0)
|
||||
{
|
||||
x--;
|
||||
y--;
|
||||
}
|
||||
}
|
||||
void pai2(int &x,int &y)
|
||||
{
|
||||
while(x<=n&&y>0)
|
||||
{
|
||||
x++;
|
||||
y--;
|
||||
}
|
||||
}
|
||||
int main()
|
||||
{
|
||||
int i,j,xx,yy;
|
||||
while(true)
|
||||
{
|
||||
cin>>n>>i>>j;
|
||||
for(int x=1;x<=n;x++) cout<<"("<<i<<","<<x<<") ";
|
||||
cout<<endl;
|
||||
for(int x=1;x<=n;x++) cout<<"("<<x<<","<<j<<") ";
|
||||
cout<<endl;
|
||||
xx=j;
|
||||
yy=i;
|
||||
pai(xx,yy);
|
||||
for(int ii=1;ii+xx<=n&&ii+yy<=n;ii++) cout<<"("<<ii+yy<<","<<ii+xx<<") ";
|
||||
xx=j;
|
||||
yy=i;
|
||||
pai2(xx,yy);
|
||||
cout<<endl;
|
||||
for(int ii=1;xx-ii>0&&ii+yy<=n;ii++) cout<<"("<<xx-ii<<","<<ii+yy<<") ";
|
||||
cout<<endl;
|
||||
}
|
||||
}
|
21
history_source/ccf 入门篇/U4/4.6.3.cpp
Normal file
21
history_source/ccf 入门篇/U4/4.6.3.cpp
Normal file
@ -0,0 +1,21 @@
|
||||
#include<iostream>
|
||||
#include<cmath>
|
||||
using namespace std;
|
||||
int main()
|
||||
{
|
||||
int n,a,b;
|
||||
while(true)
|
||||
{
|
||||
cin>>n;
|
||||
for(int i=2;i*i<n;i++)
|
||||
{
|
||||
if(n%i==0)
|
||||
{
|
||||
a=i;
|
||||
b=n/a;
|
||||
break;
|
||||
}
|
||||
}
|
||||
cout<<((a>b)?a:b)<<endl;
|
||||
}
|
||||
}
|
33
history_source/ccf 入门篇/U4/4.6.4.cpp
Normal file
33
history_source/ccf 入门篇/U4/4.6.4.cpp
Normal file
@ -0,0 +1,33 @@
|
||||
#include<iostream>
|
||||
#include<cmath>
|
||||
using namespace std;
|
||||
int main()
|
||||
{
|
||||
int money[12],ans,c,n;
|
||||
bool j;
|
||||
while(true)
|
||||
{
|
||||
j=1;
|
||||
for(int i=0;i<12;i++) cin>>money[i];
|
||||
ans=0;
|
||||
c=0;
|
||||
for(int i=0;i<12;i++)
|
||||
{
|
||||
n=300+ans;
|
||||
if(n<money[i]) {
|
||||
cout<<"-"<<i+1<<endl;
|
||||
j=0;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
ans=n-money[i];
|
||||
while(ans-100>=0) {
|
||||
ans-=100;
|
||||
c+=100;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(j) cout<<c*1.2+ans<<endl;
|
||||
}
|
||||
}
|
28
history_source/ccf 入门篇/U4/4.6.5.cpp
Normal file
28
history_source/ccf 入门篇/U4/4.6.5.cpp
Normal file
@ -0,0 +1,28 @@
|
||||
#include<iostream>
|
||||
#include<cmath>
|
||||
using namespace std;
|
||||
bool z(int a)
|
||||
{
|
||||
for(int i=2;i*i<=a;i++) if(a%i==0) return 0;
|
||||
return 1;
|
||||
}
|
||||
int main()
|
||||
{
|
||||
int a,b;
|
||||
bool d;
|
||||
while(true)
|
||||
{
|
||||
d=1;
|
||||
cin>>a>>b;
|
||||
for(int i=2;i<=((a<b)?a:b);i++)
|
||||
{
|
||||
if(z(i)){
|
||||
if(b%i==0)
|
||||
{
|
||||
if(a%i!=0) d=0;
|
||||
}}
|
||||
}
|
||||
if(d) cout<<"Yes"<<endl;
|
||||
else cout<<"No"<<endl;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user