[关闭]
@Asuna 2016-10-06T06:13:27.000000Z 字数 6590 阅读 812

题目1:Lucky Division

题意:这是一道难度极大的题。本萌妹苦思冥想许久才明白这道题要我做什么,其实就是定义了一些lucky number,含有4或者7就能叫做lucky number了。而这道题需要我们判断一个数是否是幸运数或是它的整数倍,若是则打“Yes”,否则输出“No”。

分析:这可难倒了本萌妹了。但就在本萌妹晚上敷面膜的时候突然灵光一现!原来n才1000也!于是本萌妹无耻地打了表之后把读入的n拉进去mod下每个表里的数,有等于0的就说明是,一直到结束都没有就是“No”咯。本萌妹聪明吧。

参考代码:

  1. #include<iostream>
  2. #include<cstdio>
  3. #include<cstring>
  4. #include<cmath>
  5. using namespace std;
  6. int main()
  7. {
  8. int n,k=0;
  9. int a[13]={4,7,44,47,74,77,444,447,474,477,744,747,777};
  10. cin>>n;
  11. for (int i=0; i<13; i++)
  12. {
  13. k++;
  14. if (n%a[i]==0)
  15. {
  16. cout<<"YES"<<endl;
  17. break;
  18. }
  19. }
  20. if (k==13)
  21. {
  22. cout<<"NO"<<endl;
  23. }
  24. return 0;
  25. }

题目2:Lucky Substring

题意:这是一道难度极大的题。本萌妹苦思冥想许久才明白这题我要做什么,其实就是给我们一个字符串,要我们求出到底是4出现的多还是7出现的多,如果都没出现过那就输出“-1”。

分析:这可难倒了本萌妹了。但就在本萌妹晚上泡牛奶浴的时候突然灵光一现!这题就是把字符串扫一遍过去看看4多还是7多嘛。需要注意的就是一样多的时候输出字典序小的那个就是4咯。

参考代码:

  1. #include<iostream>
  2. #include<cstdio>
  3. #include<cstdlib>
  4. #include<cmath>
  5. #include<cstring>
  6. using namespace std;
  7. int main()
  8. {
  9. char a[51];
  10. int i,sum1,sum2;
  11. cin>>a;
  12. sum1=sum2=0;
  13. for(i=0; a[i]!='\0'; i++)
  14. {
  15. if (a[i]=='4') sum1++;
  16. if (a[i]=='7') sum2++;
  17. }
  18. if((sum1==0) && (sum2==0)) cout<<"-1"<<endl;
  19. else if (sum1>=sum2) cout<<4<<endl;
  20. else if (sum1<sum2) cout<<7<<endl;
  21. return 0;
  22. }

题目3:The number of positions

题意:这是一道难度极大的题。本萌妹苦思冥想许久才明白这道题要我做什么,就是本萌妹站在一个n人的队列里,我前面的人不少于a,我的人不多于b,求本萌妹站位的所有可能数目。

分析:这可难倒了本萌妹了。但就在本萌妹晚上和姐妹夜谈的时候突然灵光一现!其实我们只要判断n-a和b的大小关系,考虑小的那个就行啦啦啦啦啦。

参考代码:

  1. #include<iostream>
  2. #include<cstdio>
  3. #include<cstring>
  4. using namespace std;
  5. int main()
  6. {
  7. int n,a,b,c,r;
  8. while (cin>>n>>a>>b)
  9. {
  10. c=n-a-1;
  11. if (c>b)
  12. {
  13. r=b+1;
  14. }
  15. else
  16. {
  17. r=c+1;
  18. }
  19. cout<<r<<endl;
  20. }
  21. return 0;
  22. }

题目4:Permutations

题意:这是一道难度极大的题。本萌妹苦思冥想许久才明白这题我要做什么,就是给我们n个k位的数字的序列,现在可以对每一个数字进行相同的操作,比如,你可以n个数字数字的第1,2位都互换掉。现在对这n个数字一系列操作后,会产生许多不同的序列,求序列的max-序列的min。

分析:这可难倒了本萌妹了。但就在本萌妹晚上刷韩剧的时候突然灵光一现!其实就是用dfs求出有k!种排列。对每一种排列,把n个数字的每一个数字按照排列的顺序重新排,得到一个新的序列,然后求出其max-min。把所有排列都求一遍得到答案。

参考代码:(冗长勿喷)

  1. #include<iostream>
  2. #include<cstdio>
  3. #include<cstring>
  4. #include<cmath>
  5. #include<algorithm>
  6. using namespace std;
  7. char c[101][101],s[101][101];
  8. int num[101],a[101],ans,n,k;
  9. void solve()
  10. {
  11. for (int i=0; i<n; i++)
  12. for (int j=0; j<k; j++)
  13. {
  14. s[i][j]=c[i][a[j]];
  15. // cout<<s[i]<<endl;
  16. }
  17. for (int i=0; i<n; i++)
  18. {
  19. int sum=0;
  20. for (int j=0; j<k; j++)
  21. {
  22. int cc=s[i][j]-'0';
  23. sum=sum*10+cc;
  24. }
  25. // cout<<sum<<endl;
  26. num[i]=sum;
  27. }
  28. sort(num,num+n);
  29. ans=min(ans,num[n-1]-num[0]);
  30. //cout<<ans<<endl;
  31. }
  32. void dfs(int x)
  33. {
  34. if (x==k)
  35. {
  36. solve(); return;
  37. }
  38. for (int i=0; i<k; i++)
  39. {
  40. bool b=true;
  41. for (int j=0; j<x; j++)
  42. {
  43. if (a[j]==i) b=false;
  44. }
  45. if (b==true)
  46. {
  47. a[x]=i;
  48. dfs(x+1);
  49. }
  50. }
  51. return ;
  52. }
  53. int main()
  54. {
  55. memset(a,0,sizeof(a));
  56. memset(num,0,sizeof(num));
  57. cin>>n>>k;
  58. for (int i=0; i<n; i++)
  59. cin>>c[i];
  60. ans=1000000000;
  61. dfs(0);
  62. cout<<ans<<endl;
  63. return 0;
  64. }

题目5:Wasted Time

题意:这是一道难度极大的题。本萌妹苦思冥想许久才明白这题我要做什么,就是给我们n个点的坐标,然后要我们在纸上用折线将这n个点连起来,一共有k张纸,连线速度为50/s,求所用总的时间。

分析:这可难倒了本萌妹了。但就在本萌妹晚上啃薯片的时候突然灵光一现!其实我们求出一张纸上的用时然后*k/50就ok啦。。。。

参考代码:

  1. #include<iostream>
  2. #include<algorithm>
  3. #include<cstdio>
  4. #include<cstring>
  5. #include<string>
  6. #include<cmath>
  7. using namespace std;
  8. double x[1001],y[1001];
  9. int main()
  10. {
  11. int n,k;
  12. double sum=0,ans,xx,yy;
  13. cin>>n>>k;
  14. for (int i=1; i<=n; i++)
  15. {
  16. cin>>x[i]>>y[i];
  17. if (i>1)
  18. {
  19. xx=(x[i]-x[i-1])*(x[i]-x[i-1]);
  20. yy=(y[i]-y[i-1])*(y[i]-y[i-1]);
  21. sum+=(sqrt(xx+yy));
  22. //cout<<i<<"shabi"<<" "<<sum<<endl;
  23. }
  24. }
  25. ans=sum*k/50.0;
  26. printf("%.9lf\n",ans);
  27. return 0;
  28. }

题目6:Canvas Frames

题意:这是一道难度极大的题。本萌妹苦思冥想许久才明白这题我要做什么,就是给我们n根木棒,问我们最多能组成多少个矩形,注意不能把棒棒掰断也不能组合它们哟。

分析:这可难倒了本萌妹了。但就在本萌妹晚上背英语单词的时候突然灵光一现!其实我们只要把相同长的棒棒两两配对,把对数/2就可以得出有多少个矩形啦啦啦啦啦啦啦啦。

参考代码:

  1. #include<iostream>
  2. using namespace std;
  3. int main()
  4. {
  5. int n,k,a[1000],ans=0;
  6. cin>>n;
  7. for (int i=1; i<=n; i++)
  8. {
  9. cin>>k;
  10. a[k]++;
  11. //cout<<a[k]<<endl;
  12. }
  13. //for (int i=1; i<=10; i++)
  14. // cout<<a[i]<<" ";
  15. for (int i=1; i<=110; i++)
  16. {
  17. while ((a[i]>=2) && (a[i]!=0))
  18. {
  19. a[i]-=2;
  20. ans++;
  21. }
  22. //for (int i=1; i<=10; i++)
  23. // cout<<a[i]<<" ";
  24. //cout<<endl;
  25. }
  26. cout<<ans/2<<endl;
  27. return 0;
  28. }

题目7:Cookies

题意:这是一道难度极大的题。本萌妹苦思冥想许久才明白这题我要做什么,就是有姐妹两个为了分物品的时候不产生矛盾,妹妹决定根据总饼干的奇偶,来偷走相应的堆数解决这个矛盾(心机婊,要是善良的我就把所有饼干都拿走这样姐姐都不知道有饼干)。

分析:这可难倒了本萌妹了。但就在本萌妹晚上yy男神的时候突然灵光一现!其实我们只需要判断最后总数量的奇偶性来决定偷走奇数堆还是偶数堆就行了呀呀呀呀呀呀。(男神果然助我一臂之力)

参考代码:

  1. #include<iostream>
  2. #include<cstdio>
  3. using namespace std;
  4. int main()
  5. {
  6. int n,sum=0,a,ji=0,ou=0;
  7. cin>>n;
  8. for (int i=1; i<=n; i++)
  9. {
  10. cin>>a;
  11. sum+=a;
  12. if ((a%2)==1) ji++;
  13. else ou++;
  14. }
  15. if ((sum%2)==1) cout<<ji<<endl;
  16. else cout<<ou<<endl;
  17. return 0;
  18. }

题目8:Students and Shoelaces

我没做你打我呀2333333333333333

题目9:cAPS lOCK

题意:这是一道难度极大的题。本萌妹苦思冥想许久才明白这题我要做什么,如果全是大写或者除了首字母是小写其他为大写,则转换为第一个字母大写,其他的小写,如果不是以上两种情况则不作处理。

分析:这可难倒了本萌妹了。但就在本萌妹晚上玩暖暖环游世界(别问我为什么知道这个游戏)的时候突然灵光一现!本萌妹不是在题意就写出解法了吗!我的天哪噜!其实需要注意的是单个字母也算!

参考代码:

  1. #include<iostream>
  2. #include<cstring>
  3. #include<cstdio>
  4. #include<cstdlib>
  5. using namespace std;
  6. int main()
  7. {
  8. char c[101];
  9. int l,s1=0,s=0;
  10. cin>>c;
  11. l=strlen(c);
  12. for (int i=1; i<l; i++)
  13. {
  14. if (c[i]>='A'&& c[i]<='Z') s++;
  15. else if (c[i]>='a'&& c[i]<='z') s1++;
  16. }
  17. if ((s1==0 && s!=0) || l==1)
  18. {
  19. if (c[0]>='a'&&c[0]<='z') c[0]-=32;
  20. else if (c[0]>='A'&&c[0]<='Z') c[0]+=32;
  21. for (int i=1; i<l; i++) c[i]+=32;
  22. cout<<c<<endl;
  23. }
  24. else cout<<c<<endl;
  25. return 0;
  26. }

题目10:Opposites Attract

我不会你来打我啊233333333333333333

题目11:The World is a Theatre

题意:这是一道难度极大的题。本萌妹苦思冥想许久才明白这题我要做什么,就是n男m女配对活动,至少4男1女在一个组里,一组有t个人。问有多少种不同的分组方法。

分析:这可难倒了本萌妹了。但就在本萌妹晚上刷牙的时候突然灵光一现!这不就是个组合问题么,我们只需要把女生初始的时候设为最少(男生就是n个,女生就是t-n个),然后进行组合,再用一个女生替换一个男生,再组合……以此类推直到把女生都用上或者男生到了4个。需要注意的是可能t< n这个需要单独考虑。

参考代码:(冗长勿喷)

  1. #include<iostream>
  2. #include<cstdio>
  3. #include<cstdlib>
  4. #include<cmath>
  5. #include<cstring>
  6. using namespace std;
  7. long long n,m,t,s1,s2,ans1,ans=0;
  8. long double sum1,sum2;
  9. long long t1,t2;
  10. void zuhe()
  11. {
  12. for (int i=1; i<=s1; i++)
  13. {
  14. sum1=sum1*t1/i;
  15. t1--;
  16. // cout<<t1<<endl;
  17. }
  18. //cout<<sum1<<endl;
  19. /*for (int i=1; i<=s1; i++)
  20. sum1/=i;
  21. */
  22. for (int i=1; i<=s2; i++)
  23. {
  24. sum2=sum2*t2/i;
  25. t2--;
  26. }
  27. //cout<<sum2<<endl;
  28. /*for (int i=1; i<=s2; i++)
  29. sum2/=i;*/
  30. ans1=sum1*sum2;
  31. }
  32. int main()
  33. {
  34. cin>>n>>m>>t;
  35. if (t>=n)
  36. {
  37. s1=n;
  38. s2=(t-s1);
  39. if (s2==0)
  40. {
  41. s2++;
  42. s1--;
  43. }
  44. while ((s1>=4) && (s2<=m))
  45. {
  46. t1=n;
  47. t2=m;
  48. sum1=1;
  49. sum2=1;
  50. zuhe();
  51. ans+=ans1;
  52. s1--;
  53. s2++;
  54. //cout<<s1<<" "<<s2<<endl;
  55. }
  56. cout<<ans<<endl;
  57. return 0;
  58. }
  59. s1=4;
  60. s2=t-s1;
  61. while ((s1<=t) && (s2>=1))
  62. {
  63. t1=n;
  64. t2=m;
  65. sum1=1;
  66. sum2=1;
  67. zuhe();
  68. ans+=ans1;
  69. s1++;
  70. s2--;
  71. }
  72. cout<<ans<<endl;
  73. return 0;
  74. }

题目12:Subway

DFS?不会做你打死我好了23333333333333333

题目13:HQ9+

题意+分析:这是一道难度极大的题。本萌妹苦思冥想许久才明白这题我要做什么,就是判断"H","Q","9"有没有,有任何一个都输出“Yes”。就这么做吧(别问我灵光一现的时候在做什么)。

参考代码:

  1. #include<iostream>
  2. #include<cstdio>
  3. #include<cstring>
  4. #include<cstdlib>
  5. using namespace std;
  6. char s[1000];
  7. int main()
  8. {
  9. int l,bo;
  10. cin>>s;
  11. l=strlen(s);
  12. bo=0;
  13. for (int i=0; i<l; i++)
  14. if ((s[i]=='Q') || (s[i]=='H') || (s[i]=='9'))
  15. {
  16. bo=1;
  17. break;
  18. }
  19. if (bo) cout<<"YES"<<endl;
  20. else cout<<"NO"<<endl;
  21. return 0;
  22. }

题目14:Unary

题意:这是一道难度极大的题。本萌妹苦思冥想许久才明白这题我要做什么,就是几个符号分别代表了2进制的几个数,然后输入几个符号连在一起我们就要把对应的2进制串在一起之后再转换成10进制,mod 10^6+3。

分析:这可难倒了本萌妹了。但就在本萌妹晚上数绵羊的时候突然灵光一现!其实我们可以把每个符号都单独先转换成10进制呀,而对于连续的符号我们只要从最后一个符号开始每向前一个都乘16再相加呀。这样就直接转换成10进制了而不需要串起来再做也不需要打表啦。

参考代码:

  1. #include<iostream>
  2. #include<cstdio>
  3. #include<cstdlib>
  4. #include<cstring>
  5. #include<string>
  6. using namespace std;
  7. char s[1000],c[8];
  8. int main()
  9. {
  10. c[0]='>';
  11. c[1]='<';
  12. c[2]='+';
  13. c[3]='-';
  14. c[4]='.';
  15. c[5]=',';
  16. c[6]='[';
  17. c[7]=']';
  18. //cout<<c<<endl;
  19. int l,j=0,ans=0;
  20. cin>>s;
  21. l=strlen(s);
  22. //cout<<l<<endl;
  23. for (int i=0; i<l; i++)
  24. {
  25. while ((c[j]!=s[i]))
  26. {
  27. //cout<<c[j]<<endl;
  28. j++;
  29. }
  30. ans=(ans*16+8+j)%1000003;
  31. j=0;
  32. }
  33. cout<<ans<<endl;
  34. return 0;
  35. }

题目15:Caesar's Legions

本萌妹睡了抱歉。

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注