????? 這次比賽原本就是來打醬油的,想做個簽到題就走!一開始不知道1002是簽到題,一直死磕1001,WA了四發過了,回頭一看Rank,三十名,我靠!看了1001的AC率,在我AC之前只有一個人AC了,當時我AC了1001,感覺松了口氣,終于算是簽到了,看AC率,1%,嚇死寶寶了!我啥時候變得這么屌了,連我們學校的大佬都沒AC出來,被我這樣一個菜雞給AC了,頓時感覺信心回來了,然后我的電腦上插了一個氣球,莫名其妙,還有氣球???回頭看1002,我靠,WA了三發,什么情況,10^9,肯定超時,WA了一發,原本想什么快速冪弄出來,我真是傻了眼,又WA了兩發,我靜下心來想想,人家最快27秒AC,不可能很復雜,結果再讀了一遍題目,被坑啦!就總共兩種情況,n=0和n!=0的情況,然后AC了!Rank 15~~,然后1005我就不說了,估計是沒有想清楚,WA了5發,最后Rank 21結束,沒辦法咯!好好學吧!為了自己的未來,加油!
1001--------------------------------------------------------------------------------------------------------------------------
三種橙子
Time Limit : 3000/1000ms (Java/Other)???Memory Limit : 65535/32768K (Java/Other)
Total Submission(s) : 201???Accepted Submission(s) : 7
Font: Times New Roman | Verdana | Georgia
Font Size: ← →
Problem Description
Input
Output
Sample Input
5 4 3 1 1 1 2 3 3
Sample Output
4 1 2對于第一組數據 我們可以劃分為 gbb rgg brr rrg g表示綠蘋果,r表示紅蘋果,b表示青蘋果
Author
1 #include <bits/stdc++.h> 2 using namespace std; 3 int main() 4 { 5 long long a,b,c; 6 while(scanf("%lld%lld%lld",&a,&b,&c)!=EOF) 7 { 8 long long s=a+b+c; 9 long long x,y,z; 10 if(a>=b) 11 { 12 if(a>=c) 13 { 14 x=a; 15 if(b>=c) 16 y=c; 17 else y=b; 18 } 19 else x=c; 20 } 21 else 22 { 23 if(a>=c) 24 x=b; 25 else 26 { 27 y=a; 28 if(b>=c) 29 x=b; 30 else x=c; 31 } 32 } 33 z=s-x-y; 34 long long t=s/3; 35 if (y+z<=x&&s>=3) 36 { 37 if(y+z<=t) 38 printf("%lld\n",y+z); 39 else printf("%lld\n",t); 40 } 41 else 42 printf("%lld\n",s/3); 43 } 44 return 0; 45 }
1002-------------------------------------------------------------------------------------------------------------
會喊666的咸魚
Time Limit : 3000/1000ms (Java/Other)???Memory Limit : 65535/32768K (Java/Other)
Total Submission(s) : 277???Accepted Submission(s) : 53
Font: Times New Roman | Verdana | Georgia
Font Size: ← →
Problem Description
Input
Output
Sample Input
1
Sample Output
6
Author
1 #include <bits/stdc++.h> 2 using namespace std; 3 int main() 4 { 5 int n; 6 while(scanf("%d",&n)!=EOF) 7 { 8 if(n==0) 9 printf("1\n"); 10 else if(n>=1) 11 printf("6\n"); 12 } 13 return 0; 14 }
1003--------------------------------------------------------------------------------------------------------------------
學妹的告白
Time Limit : 3000/1000ms (Java/Other)???Memory Limit : 65535/32768K (Java/Other)
Total Submission(s) : 69???Accepted Submission(s) : 2
Font: Times New Roman | Verdana | Georgia
Font Size: ← →
Problem Description
太過直白反而會嚇著學長,學妹心里是這么想的,于是她想了一個游戲。
學長,我們玩一個游戲吧,“游戲?”學長滿臉疑問看著她。
哎呀,是這種的,我們現在紙上畫一個方框,平均分成n份,編號為1~n,然后呢,我們從1號開始移動k個數字,如果遇上邊界就改變方向,就是下面的樣子,比如8個格子,移動兩個數字(圖片不能正常顯示請點擊:鏈接http://pan.baidu.com/s/1eR7AHCQ)
1->3->5->7->7->5->3->1->3....如果這樣一直跳,就會出現死循環,不能把每一個格子都踩中,那么我們需要最小的k是多少時才能滿足每一個格子都踩中呢?
“那不是等于1么”學長脫口而出~
這樣就沒法玩了,難怪都這么久都沒有女朋友,當然k不能等于1!
“那我再想一想”,剛說完,學長就得到了答案,學妹失望的走了。
“奇怪,明明答案是正確的啊,怎么不開心呢?”(真實的故事)
Input
(多組輸入)
Output
k不等于1
Sample Input
8
Sample Output
31->4->7->6->3->2->5->8 全部踩中
Author
1 int flag[N]; 2 int check(int x,int n) 3 { 4 for(int i=1;i<=n;i++) 5 flag[i]=0; 6 int ans=0; 7 int st=1; 8 int dir=1; 9 while(ans<n-1) 10 { 11 if(dir) 12 st+=x; 13 else 14 st-=x; 15 if(st<=0) 16 st=2-st,dir=1; 17 else if(st>n) 18 st=2*n-st,dir=0; 19 //cout<<x<<" xxx "<<st<<endl; 20 int p=st; 21 if(flag[p])return 0; 22 ans++; 23 flag[p]=1; 24 } 25 return 1; 26 }
下面給出AC代碼:
1 #include <iostream> 2 #include <cstdio> 3 #include <cmath> 4 #include <string> 5 #include <cstring> 6 #include <algorithm> 7 #include <queue> 8 #include <map> 9 #include <set> 10 #include <stack> 11 #include <sstream> 12 #include <vector> 13 #define PI acos(-1.0) 14 #define N 111111 15 #define M 1000000007 16 #define inf 1e9 17 #define eps 1e-8 18 #define dazhi 2147483647 19 using namespace std; 20 typedef long long ll; 21 int main() 22 { 23 int a[10]= {3,5,7,11,13,17,19,23}; 24 int n; 25 while(cin>>n) 26 { 27 int l=3; 28 for(int i=0; i<7; i++) 29 { 30 if(n%l==1) 31 l*=a[i+1]; 32 else 33 { 34 printf("%d\n",a[i]); 35 break; 36 } 37 } 38 } 39 }
方案二,
如果做過HDU1222題估計會好很多,結論就是gcd(2*n-2,k)==1時,所有格子可以踩中
HDU1222是一個圈啦,這里不是,我們要看成一個圈,比如12321,我們取1232為循環,就是2*3-2(2*n-2)
下面給出AC代碼:
1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <string.h> 4 #include <math.h> 5 #include <iostream> // C++頭文件,C++完全兼容C 6 #include <algorithm> // C++頭文件,C++完全兼容C 7 #include <time.h> 8 #define fre freopen("out.txt","w",stdout) //以文件代替控制臺輸入,比賽時很常用,能縮短輸入測試樣例的時間 9 #define INF 0x3f3f3f3f 10 #define inf 1e60 11 using namespace std; // C++頭文件,C++完全兼容C 12 const int maxn = 200; 13 int a[maxn]; 14 int b[3]; 15 int ans,n,k; 16 17 int main() 18 { 19 while(cin>>n) 20 { 21 for(int i=2; i<=2*n; i++) 22 { 23 if(__gcd(2*n-2,i)==1) 24 { 25 cout<<i<<endl; 26 break; 27 } 28 } 29 } 30 31 return 0; 32 }
1004--------------------------------------------------------------------------------------------------------------------------------
豆豆的三進制計算機
Time Limit : 3000/1000ms (Java/Other)???Memory Limit : 65535/32768K (Java/Other)
Total Submission(s) : 31???Accepted Submission(s) : 2
Font: Times New Roman | Verdana | Georgia
Font Size: ← →
Problem Description
三進制是以3為基數的進制。和二進制一樣,三進制的數位,稱為三進制位(trit),每個三進制位包含 log23(約1.58個)二進制位的信息量。通常,三進制中使用0、1、2三個數字。
n!末尾有多少個0這樣的問題對于豆豆來說是非常簡單的。豆豆突然想到那么n!轉換成3進制后,末尾有多少個0呢?
Input
(多組數據)
Output
Sample Input
3
Sample Output
1
Author
Source
我們想一想十進制怎么求末尾0,嗯嗯,當然是找被10整除的個數嘍
這里情況一樣的啦,我們就一直除以3,一直除以3,找被3整除的個數
下面給出AC代碼:
1 #include <stdio.h> 2 #define freout freopen("out.txt","w",stdout) 3 #define frein freopen("in.txt","r",stdin) 4 int main () 5 { 6 // frein; 7 // freout; 8 long long n; 9 while(~scanf("%lld", &n)) 10 { 11 long long sum = 0; 12 long long tmp = 3; 13 while (n >= tmp) 14 { 15 sum += (n / tmp); 16 tmp *= 3; 17 } 18 printf("%lld\n", sum); 19 } 20 21 return 0; 22 }
1005--------------------------------------------------------------------------------------------------------------------------
袁少的游戲
Time Limit : 3000/1000ms (Java/Other)???Memory Limit : 65535/32768K (Java/Other)
Total Submission(s) : 200???Accepted Submission(s) : 24
Font: Times New Roman | Verdana | Georgia
Font Size: ← →
Problem Description
Input
然后輸入n個數。(多組輸入)
Output
Sample Input
5 1 3 3 2 1 5 1 2 3 4 5 2 1 2
Sample Output
jxust ecjtujxnu jxust第一組樣例可以通過所有的3都減一,所有的1都加一,使全部都變成2.所以輸出jxust 第三組樣例可以讓1加上1,使所有數都變成2,或者讓2減去1,使所有數都變成1,所以輸出jxust
Author
大概知道了如果數組中只存在兩種數字,必定是符合要求的
三種如何判斷,最小的數字必須增加一個數,最大的數字必須減少一個數字,他們要和中間數字相同,那么是a[3]-a[2]==a[2]-a[1]的關系
我們需要做的就是去重計算出他的種類,排序判斷
下面給出AC代碼:
1 #pragma comment(linker, "/STACK:1024000000,1024000000") 2 #include<iostream> 3 #include<cstdio> 4 #include<cmath> 5 #include<string> 6 #include<queue> 7 #include<algorithm> 8 #include<stack> 9 #include<cstring> 10 #include<vector> 11 #include<list> 12 #include<set> 13 #include<map> 14 using namespace std; 15 #define ll long long 16 #define pi (4*atan(1.0)) 17 #define eps 1e-14 18 #define bug(x) cout<<"bug"<<x<<endl; 19 const int N=1e5+10,M=1e6+10,inf=2147483647; 20 const ll INF=1e18+10,mod=2147493647; 21 ll a[N]; 22 int main() 23 { 24 int n; 25 while(~scanf("%d",&n)) 26 { 27 for(int i=1; i<=n; i++) 28 scanf("%lld",&a[i]); 29 sort(a+1,a+1+n); 30 int cnt=unique(a+1,a+1+n)-a; 31 //cout<<cnt<<endl; 32 if(cnt>4) 33 printf("ecjtujxnu\n"); 34 else 35 { 36 if(cnt<=3) 37 printf("jxust\n"); 38 else if(a[3]-a[2]==a[2]-a[1]) 39 printf("jxust\n"); 40 else 41 printf("ecjtujxnu\n"); 42 } 43 } 44 return 0; 45 }
1006---------------------------------------------------------------------------------------------------------------------------------
來相思樹下
Time Limit : 3000/1000ms (Java/Other)???Memory Limit : 65535/32768K (Java/Other)
Total Submission(s) : 32???Accepted Submission(s) : 0
Font: Times New Roman | Verdana | Georgia
Font Size: ← →
Problem Description
雖然都是妖王,但按照涂山的規定必須進行標號,標號為1的妖王排在最后面,標號為n的妖王排在最前面。每個妖王只有一個妖力值a[i]表示它們現在的地位。
妖王們是講究實力的,當然不服比它妖力值低的居然可以排在前面,它們現在想知道在它前面,妖力值比它低,而且離它最遠的距離是多少?
Input
第二行輸入n個整數,表示每個妖王的妖力值a[i]
n≤2?105
1≤a[i]≤109
(多組輸入)
Output
Sample Input
6 5 50 45 7 10 1
Sample Output
4 3 2 1 0 -1對于第一個數:5,比它小的數字是1,1距離它最遠,最遠距離為4 對于第二個數:50,比它小的數字是45 7 10 1,1距離它最遠,距離為3 對于第三個數:45,比它小的數字是7 10 1,1距離它最遠,距離為2 對于第四個數:7,比它小的數字是10 1,1距離它最遠,距離為1 對于第五個數:10,比它小的數字是1,1距離它最遠,距離為0 對于第六個數:已經沒有比它小的數字了,距離為-1
Author
我們可以二分右邊的那個區間,如果右區間的r[i]<當前的數說明可以向右延伸;
1 #pragma comment(linker, "/STACK:1024000000,1024000000") 2 #include<iostream> 3 #include<cstdio> 4 #include<cmath> 5 #include<string> 6 #include<queue> 7 #include<algorithm> 8 #include<stack> 9 #include<cstring> 10 #include<vector> 11 #include<list> 12 #include<set> 13 #include<map> 14 using namespace std; 15 #define ll long long 16 #define pi (4*atan(1.0)) 17 #define eps 1e-14 18 #define bug(x) cout<<"bug"<<x<<endl; 19 const int N=1e5+10,M=1e6+10,inf=2147483647; 20 const ll INF=1e18+10,mod=2147493647; 21 int a[N]; 22 int r[N]; 23 int main() 24 { 25 int n; 26 while(~scanf("%d",&n)) 27 { 28 for(int i=1;i<=n;i++) 29 scanf("%d",&a[i]); 30 r[n]=a[n]; 31 for(int i=n-1;i>=1;i--) 32 r[i]=min(r[i+1],a[i]); 33 for(int i=1;i<=n;i++) 34 { 35 int st=i+1; 36 int en=n,ans=-1; 37 while(st<=en) 38 { 39 int mid=(st+en)>>1; 40 if(a[i]>r[mid]) 41 { 42 st=mid+1; 43 ans=mid; 44 } 45 else 46 en=mid-1; 47 } 48 if(ans==-1) 49 printf("-1"); 50 else 51 printf("%d",ans-i-1); 52 printf("%c",((i==n)?'\n':' ')); 53 } 54 } 55 return 0; 56 }
實在不會還有這種的(利用C++STL)
下面給出AC代碼:
1 #include <cstdio> 2 #include <cstring> 3 #include <vector> 4 #include <algorithm> 5 #define MAX 200002 6 using namespace std; 7 8 int a[MAX],ans[MAX]; 9 vector<int> v,num; 10 #define freout freopen("out.txt","w",stdout) 11 #define frein freopen("in.txt","r",stdin) 12 int main() 13 { 14 15 int n; 16 while(~scanf("%d",&n)){ 17 for(int i=0;i<n;i++) scanf("%d",&a[i]); 18 v.clear(); 19 num.clear(); 20 for(int i=n-1;i>=0;i--){ 21 if(v.size()==0 || v.back()>=a[i]){ 22 v.push_back(a[i]); num.push_back(i); 23 ans[i]=-1; 24 }else{ 25 int j = (lower_bound(v.rbegin(),v.rend(),a[i]) - v.rbegin()); 26 // printf("%d %d\n",a[i],j); 27 j = (int)v.size() - j ; 28 //printf("%d %d\n",num[j+1],j); 29 ans[i] = num[j] - i - 1; 30 } 31 } 32 for(int i=0;i<n;i++){ 33 if(i) printf(" "); 34 printf("%d",ans[i]); 35 } 36 printf("\n"); 37 } 38 return 0; 39 }
?