HDOJ 1248 寒冰王座(找规律)
来源:互联网 发布:pdf笔记软件 编辑:程序博客网 时间:2024/04/29 18:42
【思路】:找规律,参考的别人的,自己写的挂了。http://blog.csdn.net/appte/article/details/8227632
【AC代码】:
#include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;int main(){ //freopen("in.txt", "r", stdin); //freopen("out.txt", "w", stdout); int T = 0; cin >> T; while (T--) { int n = 0, m = 0; cin >> n; if (n<200) m = n%150; else if (n >= 200 && n < 300) m = n%200; else if (n >= 300) m = n%50; cout << m << endl; } return 0;}
【自己写的WA代码】:1300时候就是错的,应该是0,输出50。
#include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;int main(){ //freopen("in.txt", "r", stdin); //freopen("out.txt", "w", stdout); int T = 0; cin >> T; while (T--) { int n = 0; cin >> n; int a = n%150, b = n%200, c = n%350; if (b >= 150) b %= 150; if (c >= 300) c %= 150; else if (c >= 200) c %= 200; else if (c >= 150) c %= 150; if (a < b) { if (a < c) cout << a << " "; else cout << c << " "; } else { if (b < c) cout << b << " "; else cout << c << " "; } } return 0;}
方法就是错的,几乎没法改。。
0 0
- HDOJ 1248 寒冰王座(找规律)
- hdoj 1248 寒冰王座
- HDOJ 1248 寒冰王座
- hdoj 1248 寒冰王座
- HDOJ 寒冰王座 1248
- HDOJ--1248--寒冰王座
- HDOJ 1248 寒冰王座
- HDOJ -- 1248 寒冰王座
- HDOJ--1248|寒冰王座
- hdoj 寒冰王座
- HDOJ 1248 寒冰王座 (多重背包)
- hdoj--1248--寒冰王座(完全背包)
- HDOJ 1248 寒冰王座(完全背包)
- HDOJ 1248 寒冰王座 (完全背包 || bfs)
- HDOJ 1248 寒冰王座 (完全背包)
- [完全背包]HDOJ 1248寒冰王座
- hdoj.1248 寒冰王座 20140815
- hdoj 1248 寒冰王座 【完全背包】
- POJ 2503 Babelfish (Trie树 或 map)
- 接口的使用和规则
- JS行间样式与非行间样式操作(及兼容性解决方法)
- CodeForces 222B Cosmic Tables
- 黑马程序员——OC基础---内存管理
- HDOJ 1248 寒冰王座(找规律)
- hadoop中的jps
- 页面菊花效果
- C语言------指针(二)
- 编程挑战系统的输入和输出详细说明
- Wondershare Video Converter Ultimate V8.0.5.1-DVT
- 回看腾讯这些年(文末有感)
- dfs
- QT保存设置QSetting