西邮杯决赛
来源:互联网 发布:淘宝怎么上传视频凭证 编辑:程序博客网 时间:2024/04/28 09:31
题目没公开,都是凭记忆在网上搜的相似题目,代码也没验证,如果有错误还望点出。
a * x + b * y = c;
d * x + e * y = f;
x,y代表未知数,a, b, c, d, e, f为参数。
求解x,y
数据规模和约定
0 < = a, b, c, d, e, f < = 2147483647
3 7 41 2 1 9
2 5
#include<stdio.h>#include<math.h>int main(void) { int a,b,c,d,e,f; double x; double y; int flag = 0; scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f); y = (c * d - f * a) / (b * d - e * a); x = (c - b * y) / a; if(x - fabs(x) <= 1e-6 && y - fabs(y) <= 1e-6) { flag == 1; } if((b * d - e * a) == 0 || flag == 1) { printf("NONE"); } else { printf("%d %d\n",(int)x,(int)y); } return 0;}
母牛生小牛
设有一头小母牛,从出生第四年起每年生一头小母牛,按此规律,第N年时有几头母牛?
Input
每组数据只有一个整数N,独占一行。(1≤N≤50)
Output
对每组数据,输出一个整数(独占一行)表示第N年时母牛的数量
Sample Input
1
4
5
20
Sample Output
1
2
3
872
简单递推或递归
#include<stdio.h>#include<math.h>int a[10001];int main(void) { int n; int i; a[1] = 1; a[2] = 2; a[3] = 3; scanf("%d",&n); for(i = 4;i <= n;i++) { a[i] = a[i-1] + a[i-3]; } printf("%d\n",a[n]); return 0;}
.移动距离(BY YAN)
时间限制: 10 Sec 内存限制: 256 MB提交: 758 解决: 332
[提交][状态][讨论版]
题目描述
X星球居民小区的楼房全是一样的,并且按矩阵样式排列。其楼房的编号为1,2,3...当排满一行时,从下一行相邻的楼往反方向排号。
例如:当小区排号宽度为6时,开始情形如下:
1 2 3 4 5 6
12 11 10 9 8 7
13 14 15 .....
问题是:已知了两个楼号m和n,需要求出它们之间的最短移动距离(不能斜线方向移动)
输入
输入为3个整数w m n,空格分开,都在1到10000范围内。
w为排号宽度,m,n为待计算的楼号。
输出
输出一个整数,表示m n 两楼间最短移动距离。
样例输入
6 8 2
样例输出
4
初赛原题,链接http://blog.csdn.net/yinjianxiang/article/details/73409777
#include<stdio.h> #include<math.h> typedef struct node { int x; int y; }node; node fun(int w,int n) { node tmp; tmp.x = (n-1) / w + 1; tmp.y = n % w; if (tmp.y == 0) tmp.y = w; if (tmp.x % 2 == 0) { tmp.y = w - tmp.y + 1; } return tmp; } int main(void) { node tmp_1; node tmp_2; int w; int m; int n; int res; scanf("%d %d %d",&w,&m,&n); tmp_1 = fun(w,m); tmp_2 = fun(w,n); res = abs(tmp_1.x - tmp_2.x) + abs(tmp_1.y - tmp_2.y); printf("%d\n",res); return 0; }
没有相似的题,见得讲一下题意。
3淘淘帅帅笑笑245 淘淘 45 帅帅44 笑笑45 淘淘 46 笑笑44 帅帅
输入是这样,开始输入学生个数,接着名字,但一定淘淘且第一。下面输入考试次数,还有考试的分数和名字,淘淘总是第一个。成绩相同,淘淘排在前面。
输出
1
2
主要注意输入输出,决赛就死在这上面了。
#include<stdio.h>#include<string.h>typedef struct STU{ int grade; char name[31];}STU;int main(void) { STU student[30] = {0}; int n; int m; int i; int j; char s[31]; int grade; int count = 1; scanf("%d",&n); for(i = 0;i < n;i++) { scanf("%s",student[i].name); } scanf("%d",&m); while(m--) { count = 1; for(i = 0;i < n;i++) { scanf("%d %s",&grade,s); if(i == 0) { student[0].grade = grade; } else { for(j = 1;j < n;j++) { if(strcmp(student[j].name,s) == 0) { student[j].grade = grade; } } } } for(i = 1;i < n;i++) { if(student[0].grade < student[i].grade) { count++; } } printf("%d\n",count); } return 0;}
黑色星期五
有些西方人比较迷信,如果某个月的13号正好是星期五,他们就会觉得不太吉利,用古人的说法,就是“诸事不宜”。请你编写一个程序,统计出在在这一年中,既是13号又是星期五的日期个数。
说明:(1)一年有365天,闰年有366天,所谓闰年,即能被4整除且不能被100整除的年份,或是既能被100整除也能被400整除的年份;(2)已知1998年1月1日是星期四,用户输入的年份肯定大于或等于1998年。
样例输入
1998
样例输出
3
#include<stdio.h>#include<string.h>int fun(int year) { if((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) { return 1; } else { return 0; } }int a[] = {31,29,31,30,31,30,31,31,30,31,30,31};int b[] = {31,28,31,30,31,30,31,31,30,31,30,31};int main(void) { int year; int sum = 0; int count = 0;int i; scanf("%d",&year); for(i = 1998;i < year;i++) { if(fun(year)) { sum += 366; } else { sum += 365; } } for(i = 0;i < 11;i++) { if(fun(year)) { if(i == 0) { sum += 12; } else { sum += a[i-1]; } if(sum % 7 == 1) { count++; } } else { if(i == 0) { sum += 12; } else { sum += b[i-1]; } if(sum % 7 == 1) { count++; } } } printf("%d\n",count); return 0;}
决赛打得自己都不想吐槽自己,和一个ZZ没有区别,太垃圾,就是渣。
说实话这次最大大收获就是对输入输出有了了解,有时输入输出可能比较坑。而且比赛发现自己调bug的能力有点慢,一点输入的bug调了很长时间。心态也不够好,感觉真是给小组丢脸了。小组一向都是很强,怎么会有我这样的水货。努力摆脱去水货。
- 西邮杯决赛
- 决赛
- 亚洲杯决赛
- 联赛决赛
- 期待决赛
- 决赛教训
- 汇编决赛
- 精彩的美洲杯决赛
- 中国队进决赛
- 辩论赛取胜,进入决赛
- 准备决赛了
- 决赛失利,获亚军。
- 要去决赛喽
- 昨夜冠军杯决赛回顾
- 今天凌晨欧洲杯决赛
- 奥运会男足决赛
- 进决赛了!!!
- 初赛,复赛,决赛
- 面试心得与总结---BAT、网易、蘑菇街
- CC3200 Simplelink Wi-Fi 入门指南
- Zookeeper集群搭建与启动
- 如何面试有2年java工作经验的应聘人员
- PAT--L2-013. 红色警报
- 西邮杯决赛
- Java实现简单的递归操作
- 工作3年的程序员应该具备什么技能|(转载)
- mycat
- PHPStorm.WebStrom配置本地项目与运程服务器同步
- caffe2--Operators(三)
- Android 状态机stateMachine的应用
- 面试Java程序员需具备的11个技能
- 无线网络覆盖