所有水题均被折叠
Lv.1 青铜
1201
1 #include<iostream> 2 #include<cstring> 3 #include<algorithm> 4 #include<cstdio> 5 #include<cstdlib> 6 #define ll long long 7 #define INF 2000000000000000 8 using namespace std; 9 10 int main(){ 11 ll mx=-INF,mn=INF; 12 ll N; 13 scanf("%lld",&N); 14 for(ll i=1;i<=N;i++){ 15 ll x;scanf("%lld",&x); 16 mx=max(x,mx); 17 mn=min(mn,x); 18 } 19 cout<<mn<<" "<<mx<<endl; 20 return 0; 21 }
1202
1 #include<iostream> 2 #include<cstring> 3 #include<algorithm> 4 #include<cstdio> 5 #include<cstdlib> 6 #define ll long long 7 #define INF 2000000000000000 8 using namespace std; 9 10 int main(){ 11 ll sum=0; 12 ll N; 13 scanf("%lld",&N); 14 for(ll i=1;i<=N;i++){ 15 ll x;scanf("%lld",&x); 16 sum+=x; 17 } 18 cout<<sum<<endl; 19 return 0; 20 }
1203
1 #include<iostream> 2 #include<cstring> 3 #include<algorithm> 4 #include<cstdio> 5 #include<cstdlib> 6 #include<cmath> 7 #define ll long long 8 #define eps 1e-8 9 #define INF 2000000000000000 10 using namespace std; 11 12 int main(){ 13 double x,y; 14 cin>>x>>y; 15 if(fabs(x-y)<eps) puts("yes"); 16 else puts("no"); 17 return 0; 18 }
1204
1 #include<iostream> 2 #include<cstring> 3 #include<algorithm> 4 #include<cstdio> 5 #include<vector> 6 #include<cstdlib> 7 #include<cmath> 8 #define ll long long 9 #define eps 1e-8 10 #define INF 2000000000000000 11 using namespace std; 12 13 int main(){ 14 char str1[10000]; 15 char str2[10000]; 16 scanf("%s%s",str1,str2); 17 cout<<(strstr(str1,str2)-str1+1); 18 return 0; 19 }
1205
1 #include<iostream> 2 #include<cstring> 3 #include<algorithm> 4 #include<cstdio> 5 #include<vector> 6 #include<cstdlib> 7 #include<cmath> 8 #define ll long long 9 #define eps 1e-8 10 #define INF 2000000000000000 11 using namespace std; 12 13 int main(){ 14 string str; 15 vector<string> vec; 16 while(cin>>str)vec.push_back(str); 17 for(int i=vec.size()-1;i>=0;i--){ 18 cout<<vec[i]<<" "; 19 } 20 return 0; 21 }
1206
1 #include<iostream> 2 #include<cstring> 3 #include<algorithm> 4 #include<cstdio> 5 #include<cstdlib> 6 #include<cmath> 7 #define ll long long 8 #define eps 1e-8 9 #define INF 2000000000000000 10 using namespace std; 11 12 int main(){ 13 double x,y; 14 cin>>x; 15 printf("%.2lf",x); 16 return 0; 17 }
2235
1 #include<iostream> 2 #include<cstring> 3 #include<algorithm> 4 #include<cstdio> 5 #include<vector> 6 #include<cstdlib> 7 #include<cmath> 8 #define ll long long 9 #define eps 1e-8 10 #define INF 2000000000000000 11 using namespace std; 12 13 int main(){ 14 int ans; 15 double a,b; 16 scanf("%lf%lf",&a,&b); 17 ans=a*b/10; 18 ans=floor((ans+5)/10.0)*10; 19 cout<<ans<<endl; 20 return 0; 21 }
//如果你不喜欢这些水题怎么办,请把他们A掉,一遍过
Lv.2 白银
1011
1 #include<iostream> 2 #include<algorithm> 3 #include<cstring> 4 #include<cstdio> 5 #include<cstdlib> 6 #include<queue> 7 #include<vector> 8 #include<cmath> 9 using namespace std; 10 11 int N,a[100000]; 12 13 int f(int x){ 14 if(x==1||x==0) return 1; 15 if(a[x]!=0) return a[x]; 16 17 int tmp=1; 18 for(int i=1;i<=x/2;i++){ 19 tmp+=f(i); 20 } 21 // cout<<tmp<<endl; 22 return a[x]=tmp; 23 } 24 25 int main(){ 26 scanf("%d",&N); 27 28 cout<<f(N); 29 30 return 0; 31 }
1430
1 #include<iostream> 2 #include<cstdio> 3 #include<cstdlib> 4 #include<cstring> 5 #include<algorithm> 6 using namespace std; 7 8 int x; 9 int main(){ 10 int flag=1; 11 scanf("%d",&x); 12 for(int i=2;i*i<=x;i++){ 13 if(x%i==0) flag=0;; 14 } 15 if(!flag) puts("\n"); 16 else puts("\t"); 17 return 0; 18 }
1075
1 #include<iostream> 2 #include<cstdio> 3 #include<cstdlib> 4 #include<cstring> 5 #include<algorithm> 6 using namespace std; 7 8 int N,a[204800],cnt; 9 10 int main(){ 11 memset(a,-1,sizeof(a)); 12 scanf("%d",&N); 13 for(int i=1;i<=N;i++){scanf("%d",&a[i]);} 14 sort(a+1,a+N+1); 15 for(int i=1;i<=N;i++) if(a[i]!=a[i+1])++cnt; 16 printf("%d ",cnt); 17 for(int i=1;i<=N;i++) if(a[i]!=a[i+1])printf("%d ",a[i]); 18 return 0; 19 }
1076
1 #include<iostream> 2 #include<cstdio> 3 #include<cstdlib> 4 #include<cstring> 5 #include<algorithm> 6 using namespace std; 7 8 int N,a[204800],cnt; 9 10 int main(){ 11 scanf("%d",&N); 12 for(int i=1;i<=N;i++){scanf("%d",&a[i]);} 13 sort(a+1,a+N+1); 14 for(int i=1;i<=N;i++)printf("%d ",a[i]); 15 return 0; 16 }
1083
1 #include<iostream> 2 #include<cstring> 3 #include<cstdio> 4 #include<algorithm> 5 #define MAXN 2000000 6 using namespace std; 7 int N,kase; 8 int main(){ 9 scanf("%d",&N); 10 int k=1; 11 while(N>k){ 12 N-=k;++k; 13 } 14 15 int i=0,j=0; 16 if(k&1){ 17 i=k+1,j=0; 18 while(N--){ 19 --i;++j; 20 } 21 } 22 else{ 23 i=0,j=k+1; 24 while(N--){ 25 ++i;--j; 26 } 27 } 28 printf("%d/%d",i,j); 29 return 0; 30 }
1160
1 #include<iostream> 2 #include<cstdio> 3 #include<cstdlib> 4 #include<cstring> 5 #include<algorithm> 6 using namespace std; 7 8 int a[1000][1000]; 9 int N; 10 11 void init_(){ 12 scanf("%d",&N); 13 a[500][500]=1; 14 int i=500,j=500,cnt=1; 15 for(int k=1;k<=2*N;k+=2){ 16 for(int c=1;c<=k;c++) a[i][++j]=++cnt; 17 for(int c=1;c<=k;c++) a[--i][j]=++cnt; 18 for(int c=1;c<=k+1;c++) a[i][--j]=++cnt; 19 for(int c=1;c<=k+1;c++) a[++i][j]=++cnt; 20 } 21 } 22 23 int main(){ 24 init_(); 25 int ans=0; 26 for(int i=500-(N-1)/2;i<=500+(N-1)/2;i++){ 27 for(int j=500-(N-1)/2;j<=500+(N-1)/2;j++){ 28 if(i==j||i+j==1000) ans+=a[i][j]; 29 printf("%d ",a[i][j]); 30 } 31 puts(""); 32 } 33 printf("%d ",ans); 34 35 return 0; 36 }
1212
1 #include<iostream> 2 #include<cstdio> 3 #include<cstdlib> 4 #include<cstring> 5 #include<algorithm> 6 using namespace std; 7 8 int x,y; 9 10 int gcd(int a,int b){ 11 if(b==0) return a; 12 else return gcd(b,a%b); 13 } 14 15 int main(){ 16 scanf("%d%d",&x,&y); 17 printf("%d ",gcd(x,y)); 18 return 0; 19 }
1475
1 #include<iostream> 2 #include<cstdlib> 3 #include<cstdio> 4 #include<algorithm> 5 #include<cstring> 6 #include<vector> 7 #define INF 0x3f3f3f3f 8 using namespace std; 9 10 int k,ans,p; 11 string x; 12 13 int trans(char x){ 14 if(x>='0'&&x<='9') return x-'0'; 15 else return x-'A'+10; 16 } 17 18 int pow_lrb(int b,int a){ 19 int tmp=1; 20 while(a){ 21 if(a&1) tmp*=b; 22 b*=b; 23 a>>=1; 24 } 25 return tmp; 26 } 27 28 int main(){ 29 30 cin>>x; 31 cin>>k; 32 p=x.size()-1; 33 for(int i=0;p>=0;i++){ 34 // cout<<pow_lrb(k,i)*trans(x[p])<<endl; 35 ans+=pow_lrb(k,i)*trans(x[p--]); 36 } 37 cout<<ans; 38 39 fclose(stdin);fclose(stdout);return 0; 40 }
1842
#include<iostream> #include<cstdio> #include<cstdlib> #include<cstring> #include<algorithm> using namespace std; int N; int f(int x){ if(x<0) return f(x+1)+f(x+2)+1; else return 5; } int main(){ scanf("%d",&N); printf("%d ",f(N)); return 0; }
1978
1 #include<iostream> 2 #include<cstdio> 3 #include<cstdlib> 4 #include<cstring> 5 #include<algorithm> 6 using namespace std; 7 8 int f[999],N; 9 10 int main(){ 11 f[1]=f[2]=1; 12 for(int i=3;i<=100;i++) f[i]=f[i-1]+f[i-2]; 13 14 // for(int i=1;i<=40;i++) cout<<f[i]<<" "; 15 16 scanf("%d",&N); 17 printf("%d ",f[N]); 18 return 0; 19 }
3038
1 #include<iostream> 2 #include<cstdio> 3 #include<cstdlib> 4 #include<cstring> 5 #include<algorithm> 6 using namespace std; 7 8 int N,cnt; 9 10 void f(int x){ 11 if(cnt>=10000) return; 12 if(x==1) return; 13 if(x&1) x=3*x+1; 14 else x>>=1; 15 ++cnt; 16 f(x); 17 } 18 19 int main(){ 20 scanf("%d",&N); 21 while(N--){ 22 cnt=0; 23 int x; 24 scanf("%d",&x); 25 f(x); 26 if(cnt<=10000)printf("%d ",cnt); 27 else puts("-1"); 28 } 29 return 0; 30 }
3143
1 #include<iostream> 2 #include<cstdio> 3 #include<cstdlib> 4 #include<cstring> 5 #include<algorithm> 6 using namespace std; 7 8 struct cc{int l,r;}nod[50]; 9 int N; 10 11 void print_pre(int x){ 12 printf("%d ",x); 13 if(nod[x].l) print_pre(nod[x].l); 14 if(nod[x].r) print_pre(nod[x].r); 15 } 16 17 void print_mid(int x){ 18 if(nod[x].l) print_mid(nod[x].l); 19 printf("%d ",x); 20 if(nod[x].r) print_mid(nod[x].r); 21 } 22 23 void print_aft(int x){ 24 if(nod[x].l) print_aft(nod[x].l); 25 if(nod[x].r) print_aft(nod[x].r); 26 printf("%d ",x); 27 } 28 29 int main(){ 30 scanf("%d",&N); 31 for(int i=1;i<=N;i++){ 32 scanf("%d%d",&nod[i].l,&nod[i].r); 33 } 34 print_pre(1);puts(""); 35 print_mid(1);puts(""); 36 print_aft(1);puts(""); 37 return 0; 38 }
//这里的题目如果你也不喜欢的话,那么也请把他们A掉吧,多花一丢丢时间而已
Lv.3 黄金
1014
1 #include<iostream> 2 #include<algorithm> 3 #include<cstring> 4 #include<cstdio> 5 #include<cstdlib> 6 #include<queue> 7 #include<vector> 8 #include<cmath> 9 using namespace std; 10 11 int mx,V,N,a[50],f[20005],sum; 12 13 14 int main(){ 15 scanf("%d%d",&V,&N); 16 for(int i=1;i<=N;i++){ 17 scanf("%d",&a[i]); 18 } 19 20 f[0]=1; 21 22 for(int i=1;i<=N;i++){ 23 for(int j=V;j>=a[i];j--){ 24 if(f[j-a[i]]) f[j]=1,mx=max(mx,j); 25 } 26 } 27 28 printf("%d",V-mx); 29 30 return 0; 31 }
1044
1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 #define inf 0x3f3f3f3f 6 using namespace std; 7 int a[100005],b[100005],k=0,N,que[100005]; 8 void ques1(){ 9 for(int i=1;i<=N;i++) b[i]=a[N-i+1]; 10 for(int i=1;i<=N;i++) 11 *lower_bound(que+1,que+N+1,b[i])=b[i]; 12 cout<<lower_bound(que+1,que+N+1,inf)-(que+1)<<endl; 13 } 14 15 void ques2(){ 16 int cnt=N,ans=0;; 17 for(int i=1;i<=N;i++){ 18 if(a[i]!=-1){ 19 if(cnt<=0) break; 20 ans++;cnt--; 21 int x=a[i]; 22 for(int j=i+1;j<=N;j++){ 23 if(a[j]<=x&&a[j]!=-1){ 24 x=a[j]; 25 a[j]=-1; 26 cnt--; 27 } 28 } 29 // cout<<cnt<<endl; 30 } 31 } 32 cout<<ans<<endl; 33 } 34 35 int main(){ 36 // freopen("01.in","r",stdin); 37 fill(que,que+100000,inf); 38 while(scanf("%d",&a[++k])==1); 39 N=k-1; 40 41 ques1(); 42 ques2(); 43 44 return 0; 45 }
1098
1 #include<iostream> 2 #include<algorithm> 3 #include<cstring> 4 #include<cstdio> 5 #include<cstdlib> 6 #include<queue> 7 #include<vector> 8 #include<cmath> 9 using namespace std; 10 11 int a[1050],N,aver,sum,cnt; 12 int main(){ 13 freopen("01.in","r",stdin); 14 scanf("%d",&N); 15 for(int i=1;i<=N;i++){ 16 scanf("%d",&a[i]); 17 sum+=a[i]; 18 } 19 aver=sum/N; 20 21 for(int i=1;i<=N;i++){ 22 if(a[i]<aver){ 23 int block=aver-a[i]; 24 a[i+1]-=block; 25 ++cnt; 26 } 27 else if(a[i]>aver){ 28 int block=a[i]-aver; 29 a[i+1]+=block; 30 ++cnt; 31 } 32 } 33 printf("%d ",cnt); 34 return 0; 35 }
1116
1 #include<iostream> 2 #include<algorithm> 3 #include<cstring> 4 #include<cstdio> 5 #include<cstdlib> 6 #include<queue> 7 #include<vector> 8 #include<cmath> 9 using namespace std; 10 11 int N,ans,e[15][15]; 12 int c[10]; 13 14 void dfs(int x){ 15 if(x>N){ 16 for(int i = 1; i <= N; i++) 17 for(int j = 1; j <= N; j++) 18 if(e[i][j] && (c[i] == c[j])) return ; 19 ++ans; 20 return; 21 } 22 23 //check 24 for(int k=1;k<=4;k++){ 25 c[x]=k; 26 dfs(x+1); 27 c[x]=0; 28 } 29 } 30 31 int main(){ 32 scanf("%d",&N); 33 34 for(int i=1;i<=N;i++){ 35 for(int j=1;j<=N;j++){ 36 scanf("%d",&e[i][j]); 37 } 38 } 39 dfs(1); 40 cout<<ans<<endl; 41 return 0; 42 }
1219
1 #include<iostream> 2 #include<cstring> 3 #include<algorithm> 4 #include<cstdio> 5 #include<vector> 6 #include<cstdlib> 7 #define ll long long 8 using namespace std; 9 10 ll f[500][500]; 11 ll N,M; 12 ll a[9]; 13 14 int main(){ 15 scanf("%lld%lld",&N,&M); 16 for(ll i=1;i<=4;i++) scanf("%lld",&a[i]); 17 18 f[a[1]][a[2]]=1; 19 for(ll i=1;i<=50;i++){ 20 for(ll j=1;j<=50;j++){ 21 if(i-2>0&&j-1>0)f[i][j]+=f[i-2][j-1]; 22 if(i-2>0 )f[i][j]+=f[i-2][j+1]; 23 if(i-1>0&&j-2>0)f[i][j]+=f[i-1][j-2]; 24 if(i-1>0 )f[i][j]+=f[i-1][j+2]; 25 } 26 } 27 28 29 printf("%lld ",f[a[3]][a[4]]); 30 31 return 0; 32 }
1220
1 #include<iostream> 2 #include<cstring> 3 #include<algorithm> 4 #include<cstdio> 5 #include<vector> 6 #include<cstdlib> 7 using namespace std; 8 9 int a[500][500],f[500][500]; 10 int N; 11 12 int main(){ 13 14 scanf("%d",&N); 15 for(int i=1;i<=N;i++){ 16 for(int j=1;j<=i;j++){ 17 scanf("%d",&a[i][j]); 18 } 19 } 20 21 for(int i=N;i>=1;i--){ 22 for(int j=1;j<=i;j++){ 23 f[i][j]=max(f[i+1][j],f[i+1][j+1])+a[i][j]; 24 } 25 } 26 27 printf("%d ",f[1][1]); 28 29 return 0; 30 }
1294
1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 #define inf 0x3f3f3f3f 6 using namespace std; 7 int a[15],b[15],used[15],N; 8 9 void f(int x,int dep){ 10 b[dep]=x; 11 if(dep==N){ 12 for(int i=1;i<=N;i++){ 13 printf("%d ",b[i]); 14 } 15 puts(""); 16 return; 17 } 18 19 used[x]=1; 20 21 for(int i=1;i<=N;i++){ 22 if(!used[i]) f(i,dep+1); 23 } 24 25 used[x]=0; 26 } 27 28 int main(){ 29 scanf("%d",&N); 30 for(int i=1;i<=N;i++){ 31 f(i,1); 32 } 33 return 0; 34 }
1576
1 #include<iostream> 2 #include<algorithm> 3 #include<cstring> 4 #include<cstdio> 5 #include<cstdlib> 6 #include<queue> 7 #include<vector> 8 #include<cmath> 9 #define ll long long 10 #define INF 21474747473434 11 using namespace std; 12 13 ll a[10050],N,f[10050]; 14 int main(){ 15 memset(f,127,sizeof(f)); 16 scanf("%lld",&N); 17 for(ll i=0;i<N;i++){ 18 scanf("%lld",&a[i]); 19 } 20 21 for(ll i=0;i<N;i++){ 22 if(*lower_bound(f,f+N,a[i])==a[i]) continue; 23 *upper_bound(f,f+N,a[i])=a[i]; 24 } 25 26 ll k=lower_bound(f,f+N,INF)-f; 27 printf("%lld ",k); 28 return 0; 29 }
3115
1 #include<iostream> 2 #include<cstring> 3 #include<algorithm> 4 #include<cstdio> 5 #include<vector> 6 #include<cstdlib> 7 using namespace std; 8 9 10 char tmpa[999],tmpb[999]; 11 int a[999],b[999],c[999]; 12 13 void mi(){ 14 for(int i=1;i<=max(a[0],b[0]);i++){ 15 c[i]+=a[i]-b[i]; 16 if(c[i]<0){ 17 c[i]+=10; 18 c[i+1]-=1; 19 } 20 } 21 c[0]=max(a[0],b[0]); 22 while(!c[c[0]]) --c[0]; 23 } 24 25 int check(){//a>b,return 1 26 if(a[0]!=b[0]){return a[0]>b[0];} 27 else{ 28 for(int i=a[0];i>=1;i--){ 29 if(a[i]<b[i]) return 0; 30 } 31 } 32 33 puts("0"); 34 exit(0); 35 } 36 37 int main(){ 38 39 scanf("%s%s",tmpa+1,tmpb+1); 40 int lena=strlen(tmpa+1),lenb=strlen(tmpb+1); 41 for(int i=lena;i>=1;i--){a[i]=tmpa[lena-i+1]-'0';} 42 for(int i=lenb;i>=1;i--){b[i]=tmpb[lenb-i+1]-'0';} 43 a[0]=lena,b[0]=lenb; 44 45 // for(int i=1;i<=lena;i++) printf("%d",a[i]); 46 // puts(""); 47 // for(int i=1;i<=lenb;i++) printf("%d",b[i]); 48 // puts(""); 49 50 if(check()){//如果a>b 51 mi(); 52 } 53 else{ 54 swap(a,b); 55 printf("-"); 56 mi(); 57 } 58 59 for(int i=c[0];i>=1;i--){ 60 printf("%d",c[i]); 61 } 62 63 return 0; 64 }
3116
1 #include<iostream> 2 #include<cstring> 3 #include<algorithm> 4 #include<cstdio> 5 #include<vector> 6 #include<cstdlib> 7 using namespace std; 8 9 10 char tmpa[999],tmpb[999]; 11 int a[999],b[999],c[999]; 12 13 void pl(){ 14 for(int i=1;i<=max(a[0],b[0]);i++){ 15 c[i]+=a[i]+b[i]; 16 if(c[i]>=10){ 17 c[i]-=10; 18 c[i+1]+=1; 19 } 20 } 21 c[0]=max(a[0],b[0]); 22 if(c[c[0]+1]) ++c[0]; 23 } 24 25 int main(){ 26 scanf("%s%s",tmpa+1,tmpb+1); 27 int lena=strlen(tmpa+1),lenb=strlen(tmpb+1); 28 for(int i=lena;i>=1;i--){a[i]=tmpa[lena-i+1]-'0';} 29 for(int i=lenb;i>=1;i--){b[i]=tmpb[lenb-i+1]-'0';} 30 a[0]=lena,b[0]=lenb; 31 32 // for(int i=1;i<=lena;i++) printf("%d",a[i]); 33 // puts(""); 34 // for(int i=1;i<=lenb;i++) printf("%d",b[i]); 35 // puts(""); 36 37 pl(); 38 39 for(int i=c[0];i>=1;i--){ 40 printf("%d",c[i]); 41 } 42 43 44 return 0; 45 }
//断更,做不下去了QAQ
//看了下时间,害怕