第一题,很水,直接上代码

  1. #include <iostream>
  2. #include <fstream>
  3. #include <cstdlib>
  4. /* run this program using the console pauser or add your own getch, system("pause") or input loop */
  5. using namespace std;
  6.  
  7. ifstream fin("coin.in");
  8. ofstream fout("coin.out");
  9.  
  10. int cnt_shu;
  11. long long he=;
  12.  
  13. int main(int argc, char** argv) {
  14. fin>>cnt_shu;
  15. int shi=;
  16. for(int x=;x<=cnt_shu;x+=shi){
  17. shi++;
  18. if(x+shi-<=cnt_shu)he+=shi*shi;
  19. else he+=(cnt_shu-x+)*shi;
  20. }
  21. fout<<he;
  22. return ;
  23. }

第二题,同样很水

  1. #include <iostream>
  2. #include <fstream>
  3. #include <cstdlib>
  4. #include <string>
  5. /* run this program using the console pauser or add your own getch, system("pause") or input loop */
  6. using namespace std;
  7.  
  8. ifstream fin("mine.in");
  9. ofstream fout("mine.out");
  10.  
  11. int cnt_hang=,cnt_lie=;
  12. int jv[][];
  13. int hez[]={,-,,,,-,,-};
  14. int zoz[]={,,,-,,-,-,};
  15.  
  16. int zhao(int he,int zo){
  17.  
  18. int ans=;
  19. for(int x=;x<;x++){
  20. int han=he+hez[x];
  21. int zon=zo+zoz[x];
  22. if(he<||zo<||he>cnt_hang||zo>cnt_lie)continue;
  23. if(jv[han][zon]==)continue;
  24. else ans++;
  25. }
  26. return ans;
  27. }
  28.  
  29. int main(int argc, char** argv) {
  30. fin>>cnt_hang>>cnt_lie;
  31. for(int x=;x<=cnt_hang;x++){
  32. string a;fin>>a;
  33. for(int y=;y<=cnt_lie;y++)if(a[y-]=='*')jv[x][y]=;
  34. }
  35. for(int x=;x<=cnt_hang;x++){
  36. for(int y=;y<=cnt_lie;y++){
  37. if(jv[x][y]==)fout<<zhao(x,y);
  38. else fout<<"*";
  39. }
  40. fout<<endl;
  41. }
  42. return ;
  43. }

第三题本来信心满满以为可以过,结果学军的数据测出来知过了2组,本以为没有希望了,结果官方测出是60分,还有40分是因为最后一步作死的没有mod,233.

我是找了规律才勉强将官方数据A过,学军的,真心做不到.

  1. #include <iostream>
  2. #include <fstream>
  3. #include <cstdlib>
  4. #include <cstring>
  5. /* run this program using the console pauser or add your own getch, system("pause") or input loop */
  6. using namespace std;
  7.  
  8. ifstream fin("sum.in");
  9. ofstream fout("sum.out");
  10.  
  11. int cnt_ge,cnt_col=;
  12. int id_num[];
  13. int head[],cnt=;
  14. int zhan[][];
  15. int zhan2[];
  16. long long ans;
  17. struct lian{
  18. int nxt;
  19. int to;
  20. };
  21. lian cun[];
  22.  
  23. void add(int sze,int yan);
  24. void sou(int yan);
  25. void suan_he(int ces);
  26.  
  27. void add(int sze,int yan){
  28. cnt++;
  29. cun[cnt].to=sze;
  30. cun[cnt].nxt=head[yan];
  31. head[yan]=cnt;
  32. return;
  33. }
  34.  
  35. int gs1=,gs2=;
  36. long long he1=0ll,he2=0ll;
  37. void sou(int yan){
  38. memset(zhan,,sizeof(zhan));
  39. int sze=cun[head[yan]].to;
  40. gs1=,gs2=;
  41. he1=0ll,he2=0ll;
  42. for(int x=head[yan];x!=-;x=cun[x].nxt){
  43. int dao=cun[x].to;
  44. if((dao+sze)%==){
  45. he1+=dao;gs1++;
  46. zhan[][gs1]=dao;
  47. }
  48. else{
  49. he2+=dao;gs2++;
  50. zhan[][gs2]=dao;
  51. }
  52. }
  53.  
  54. for(int x=;x<;x++)suan_he(x);
  55. return;
  56. }
  57.  
  58. void suan_he(int ces){
  59. int gs=;long long he=0ll;
  60. if(ces==){gs=gs1;he=he1;}
  61. else {gs=gs2;he=he2;}
  62. if(gs==||gs==)return;
  63. int shu=;
  64. for(int x=gs;x>=;x--){
  65. shu=((he+zhan[ces][x])/*id_num[zhan[ces][x]])*;
  66. ans+=shu*%;
  67. ans*=;
  68. }
  69.  
  70. return;
  71. }
  72.  
  73. int main(int argc, char** argv) {
  74. fin>>cnt_ge>>cnt_col;
  75. memset(head,-,sizeof(head));
  76. for(int x=;x<=cnt_ge;x++)fin>>id_num[x];
  77. for(int x=;x<=cnt_ge;x++){
  78. int yan;fin>>yan;
  79. add(x,yan);
  80. }
  81. for(int x=;x<=cnt_col;x++){
  82. sou(x);
  83. }
  84. fout<<ans%;
  85. return ;
  86. }

第四题,我到现在为止都不知道它为什么学军的数据A过,官方数据A过,在我心中,这种算法本身就是错误的,我是想将选所有人的情况

都算出来,然后再一个一个减的(用了传说中的优先队列),怎么对的完,是数据太弱了,还是我运气太好了,还是说我的方法本身就是正确的???

  1. #include <iostream>
  2. #include <fstream>
  3. #include <cstdlib>
  4. #include <cstring>
  5. /* run this program using the console pauser or add your own getch, system("pause") or input loop */
  6. using namespace std;
  7.  
  8. ifstream fin("salesman.in");
  9. ofstream fout("salesman.out");
  10.  
  11. int cnt_shu;
  12. int jv[];
  13. int a[];
  14. int ans[];
  15. int shang[];
  16. int hou[];
  17. int gs=;
  18. int dui[];
  19. int wei;
  20. void pout(int sze);
  21. void zhuan( );
  22. void na(int sze);
  23.  
  24. void pout(int sze){
  25. gs++;dui[gs]=sze;
  26. int now=gs,fu;
  27. while(now/>){
  28. fu=now/;
  29. if(a[dui[fu]]<a[dui[now]])return;
  30. int b=dui[fu];dui[fu]=dui[now];dui[now]=b;
  31. now=fu;
  32. }
  33. return;
  34. }
  35.  
  36. void zhuan( ){
  37. for(int x=;x<=cnt_shu;x++)shang[x]=x-;
  38. for(int x=;x<cnt_shu;x++)hou[x]=x+;
  39. for(int x=;x<cnt_shu;x++){
  40. int dai1=a[dui[]];
  41. int dai2=(jv[wei]-jv[shang[wei]])*+a[wei];
  42. if(dai1>=dai2){
  43. ans[cnt_shu-x]=ans[cnt_shu-x+]-dai2;
  44. wei=shang[wei]; na(wei);
  45. }
  46. else{
  47. hou[shang[dui[]]]=hou[dui[]];
  48. shang[hou[dui[]]]=shang[dui[]];
  49. na();
  50. ans[cnt_shu-x]=ans[cnt_shu-x+]-dai1;
  51.  
  52. }
  53. }
  54. return;
  55. }
  56.  
  57. void na(int sze){
  58. dui[sze]=dui[gs];
  59. gs--;
  60. int now=sze,zi=;
  61. while(now*<=gs){
  62. zi=now*;
  63. if(a[dui[zi+]]<a[dui[zi]]&&now*<gs)zi++;
  64. if(a[dui[zi]]>a[dui[now]])return;
  65. int b=dui[zi];dui[zi]=dui[now];
  66. dui[now]=b;now=zi;
  67. }
  68. return;
  69. }
  70.  
  71. int main(int argc, char** argv) {
  72. fin>>cnt_shu;
  73. for(int x=;x<=cnt_shu;x++){
  74. fin>>jv[x];ans[cnt_shu]=jv[x]*;
  75. }
  76. for(int x=;x<=cnt_shu;x++){
  77. fin>>a[x];
  78. if(x!=cnt_shu)pout(x);
  79. ans[cnt_shu]+=a[x];
  80. }
  81. wei=cnt_shu;
  82. zhuan( );
  83. for(int x=;x<=cnt_shu;x++)fout<<ans[x]<<endl;
  84.  
  85. return ;
  86. }

[NOIP2015pj题解]From某因为时间快了那么一点点超过下一位的蒟蒻(其实是纯代码).的更多相关文章

  1. Websphere设置JVM时区解决程序、日志时间快8小时问题

    原文链接:http://www.itpub.net/thread-1204714-1-1.html 相信很多使用Websphere的朋友会经常在Windows操作系统中遇到程序时间快8小时的问题 如果 ...

  2. noip2013Day2T3-华容道【一个蒟蒻的详细题解】

    描述 小 B 最近迷上了华容道,可是他总是要花很长的时间才能完成一次.于是,他想到用编程来完成华容道:给定一种局面,华容道是否根本就无法完成,如果能完成,最少需要多少时间. 小 B 玩的华容道与经典的 ...

  3. USACO 简易题解(蒟蒻的题解)

    蒟蒻难得可以去比赛,GDOI也快到了,还是认真刷题(不会告诉你之前都在颓废),KPM 神犇既然都推荐刷USACO, 辣就刷刷. 现在蒟蒻还没刷完,太蒟刷得太慢,so 写了的搞个简易题解(没代码,反正N ...

  4. 解决Mysql连接池被关闭 ,hibernate尝试连接不能连接的问题。 (默认mysql连接池可以访问的时间为8小时,如果超过8小时没有连接,mysql会自动关闭连接池。系统发布第二天访问链接关闭问题。

    解决Mysql连接池被关闭  ,hibernate尝试连接不能连接的问题. (默认MySQL连接池可以访问的时间为8小时,如果超过8小时没有连接,mysql会自动关闭连接池. 所以系统发布第二天访问会 ...

  5. 【第三课】ANR和OOM——贪快和贪多的后果(下)

    Out of Mana,法力耗尽. 内存就像法力,耗尽了就什么都不能做了.有时候一个应用程序占用了太大的内存,超过了Android系统为你规定的限制,那么系统就会干掉你,以保证其他app有足够的内存. ...

  6. MySQL-Front 出现“程序注册时间到期 程序将被限制模式下运行”解决方式

    MySQL-Front 出现“程序注册时间到期 程序将被限制模式下运行”解决方式 在用mysql-front的时候遇到显示:程序注册时间到期程序将被限制模式下运行.可以在“帮助”菜单下的点“登记”-- ...

  7. C#关于时间(获取特定格式的时间及多种方式获取当前时间戳)以及10位和13位时间戳转为特定格式

    C#关于时间(获取特定格式的时间及多种方式获取当前时间戳)以及10位和13位时间戳转为特定格式 置顶 2018年03月06日 19:16:51 黎筱曦 阅读数:19098 标签: C#时间 更多 个人 ...

  8. 【Cantor表】蒟蒻题解

    原题:传送门 (上图摘自网站OpenJudge - NOI题库2.1 Cantor表) 本蒟蒻的题解,让大神们见笑了! 首先,进行找规律. 大家可以发现: 1.当分子是一的时候,且分子和分母的和是偶数 ...

  9. 题解 P2920 【[USACO08NOV]时间管理Time Management】

    题面 作为一名忙碌的商人,约翰知道必须高效地安排他的时间.他有N工作要 做,比如给奶牛挤奶,清洗牛棚,修理栅栏之类的. 为了高效,列出了所有工作的清单.第i分工作需要T_i单位的时间来完成,而 且必须 ...

随机推荐

  1. js 保留小数位数

    eg: var num=3.1415926 小数位处理:num.toFixed(n)      n:小数位数

  2. C#如何释放已经加载的图片 (转)

    使用Image.FromFile取磁盘上的图片时,这个方法会锁定图片文件,而且会导致内存占用增大, 有几种方法解决: 一:将Image类转换成Bitmap类 System.Drawing.Image ...

  3. centos 7.0防火墙导致vagrant端口映射失败

    在vagrant上部署了centos7.0后,Vagrantfile端口转发设置后,宿主机访问客户机站点还是无法访问,问题出在:centos7.0以上版本默认会安装firewalld防火墙, fire ...

  4. 安装ImageMagick扩展出现configure: error: not found. Please provide a path to MagickWand-config or Wand- config program

    安装ImageMagick扩展报错: checking ImageMagick MagickWand API configuration program... checking Testing /u ...

  5. WAMP(Windows+Apache+Mysql+PHP)环境搭建

    学习PHP已经有一段时间,一直没有写过关于开发环境搭建的笔记,现在补上吧,因为安装配置的步骤记得不是很清楚,借鉴了一些别人的经验,总结如下: 首先去官方网站下载各个软件,下载需要的版本: Apache ...

  6. __name__ == '__main__'的作用

    当你打开一个.py文件时,经常会在代码的最下面看到if __name__ == '__main__':,现在就来介 绍一下它的作用. 模块是对象,并且所有的模块都有一个内置属性 __name__.一个 ...

  7. Python 3中套接字编程中遇到TypeError: 'str' does not support the buffer interface的解决办法

    转自:http://blog.csdn.net/chuanchuan608/article/details/17915959 目前正在学习python,使用的工具为python3.2.3.发现3x版本 ...

  8. JSP中使用的模式——JSP+JavaBean

    模式二:JSP+Servlet+JavaBean 链接地址:http://wxmimperio.coding.io/?p=189 JSP中两种模式的总结 链接地址:http://wxmimperio. ...

  9. BZOI 1507 [NOI2003] Editor

    Background After trying to solve problem EDIT1(Editor) and being ****ed by Brainf**k, Blue Mary deci ...

  10. OTG线与普通USB线的区别

    转自OTG线与普通USB线的区别 USB数据线是我们常见的设备,OTG线作为近年来随着手机行业的快速发展,逐步进入了我们的日常使用范围.OTG线与普通USB线的有什么区别?       USB数据线用 ...