POJ1008 1013 1207 2105 2499(全部水题)
做了一天水题,挑几个还算凑合的发上来。
POJ1008 Maya Calendar
分析:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath> using namespace std; char Haab[][] = {"pop", "no", "zip", "zotz", "tzec", "xul", "yoxkin", "mol",
"chen", "yax", "zac", "ceh", "mac", "kankin", "muan", "pax", "koyab", "cumhu", "uayet"}; char Tzo[][] = {"imix", "ik", "akbal", "kan", "chicchan", "cimi", "manik", "lamat",
"muluk", "ok", "chuen", "eb", "ben", "ix", "mem", "cib", "caban", "eznab", "canac", "ahau"}; int main() {
int year, day, cnt, month;
char szmonth[];
int T; scanf("%d", &T); printf("%d\n", T);
for(int k=; k<T; k++) {
scanf("%d.%s%d", &day, szmonth, &year); for(int i=; i<; i++) if(strcmp(Haab[i], szmonth) == ) month = i; cnt = year*+month*+day+; int ty=, td=, tm=; ty=(cnt-+)/-;
tm=(cnt-+)%;
td=(cnt-+)%+; printf("%d %s %d\n", td, Tzo[tm], ty);
} return ;
}
POJ1013 Counterfeit Dollar
分析:
超级暴力:分别对A~L这12个字母枚举轻重两种情况。
#include <iostream>
#include <cstdio>
#include <cstring> using namespace std; char _left[][], _right[][], cond[][]; int cmp(char s1[], char s2[], int k, int j) {
/*
* 用来比较天平的平衡
* 右边up 返回 1
* 平衡 返回 0
* 右边down 返回 -1
*/
int len = strlen(s1);
int lef, rig;
lef = rig = ; for(int i=; i<len; i++) {
if(s1[i] == 'A'+k) lef += j;
if(s2[i] == 'A'+k) rig += j;
} if(lef < rig) return ;
else if(lef == rig) return ;
else return -;
} int main(){
int T, i, c, j;
scanf("%d", &T); while(T--) {
for(i=; i<; i++) {
scanf("%s %s %s", _left[i], _right[i], cond[i]);
} for(i=; i<; i++) { //分别枚举12个字母
for(j=-; j<=; j++) { //轻重两种情况
if(j==) continue; for(c=; c<; c++) { //三组
int res = cmp(_left[c], _right[c], i, j);
if( ! ((res == && cond[c][] == 'u') ||
(res == && cond[c][] == 'e') ||
(res == - && cond[c][] == 'd')))
break;
}
if(c >= ) break;
}
if(c >= ) break;
} printf("%c is the counterfeit coin and it is ", i+'A');
if(j == -) printf("heavy.\n");
else printf("light.\n");
} return ;
}
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath> using namespace std; const int maxn = +; int hash[maxn]; int get(int n) {
if(!hash[n]) {
int t = n;
int cnt = ;
while(true) {
cnt++;
if(n == ) return (hash[t] = cnt);
if(n % == ) n = *n+;
else n = n/;
}
}
else return hash[n];
} int main() {
int a, b, n, m; memset(hash, , sizeof(hash)); while(scanf("%d %d", &n, &m) == ) {
a = n, b = m;
if(a > b) swap(a, b);
int max_v = -;
for(int i=a; i<=b; i++) {
if(max_v < get(i)) {
max_v = get(i);
}
} printf("%d %d %d\n", n, m, max_v);
} return ;
}
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath> using namespace std; const int maxn = ; char s[maxn]; int main() {
int n;
scanf("%d", &n); while(n--) {
scanf("%s", s); for(int i=; i<; i++) {
int ans = ;
for(int j=; j<; j++) {
ans += (s[i*+j]-'')*(<<(-j));
}
if(i == ) printf("%d", ans);
else printf(".%d", ans);
}
putchar('\n');
} return ;
}
分析:
用减的话会超时的。用除省时间。
#include <iostream>
#include <cstdio> using namespace std; int main(){
int n, a, b;
int cnt1, cnt2;
scanf("%d", &n);
for(int kase=; kase<=n; kase++) {
cnt1 = cnt2 = ;
scanf("%d%d", &a, &b); while(a != b) {
if(a > b) {
cnt1 += a/b;
a %= b;
if(a == ) {
cnt1--; break;
}
}
else {
cnt2 += b/a;
b %= a;
if(b == ) {
cnt2--; break;
}
}
} printf("Scenario #%d:\n", kase);
printf("%d %d\n\n", cnt1, cnt2);
}
return ;
}
POJ1008 1013 1207 2105 2499(全部水题)的更多相关文章
- poj 2105 IP Address(水题)
一.Description Suppose you are reading byte streams from any device, representing IP addresses. Your ...
- 【转】POJ百道水题列表
以下是poj百道水题,新手可以考虑从这里刷起 搜索1002 Fire Net1004 Anagrams by Stack1005 Jugs1008 Gnome Tetravex1091 Knight ...
- 【BZOJ】初级水题列表——献给那些想要进军BZOJ的OIers(自用,怕荒废了最后的六月考试月,刷刷水题,水水更健康)
BZOJ初级水题列表——献给那些想要进军BZOJ的OIers 代码长度解释一切! 注:以下代码描述均为C++ RunID User Problem Result Memory Time Code_Le ...
- POJ 水题(刷题)进阶
转载请注明出处:優YoU http://blog.csdn.net/lyy289065406/article/details/6642573 部分解题报告添加新内容,除了原有的"大致题意&q ...
- HDOJ 2317. Nasty Hacks 模拟水题
Nasty Hacks Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Tota ...
- ACM :漫漫上学路 -DP -水题
CSU 1772 漫漫上学路 Time Limit: 1000MS Memory Limit: 131072KB 64bit IO Format: %lld & %llu Submit ...
- ytu 1050:写一个函数,使给定的一个二维数组(3×3)转置,即行列互换(水题)
1050: 写一个函数,使给定的一个二维数组(3×3)转置,即行列互换 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 154 Solved: 112[ ...
- [poj2247] Humble Numbers (DP水题)
DP 水题 Description A number whose only prime factors are 2,3,5 or 7 is called a humble number. The se ...
- gdutcode 1195: 相信我这是水题 GDUT中有个风云人物pigofzhou,是冰点奇迹队的主代码手,
1195: 相信我这是水题 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 821 Solved: 219 Description GDUT中有个风云人 ...
随机推荐
- Linux(SLES)挂载NTFS移动硬盘实践
问题描写叙述: 因为通过測试环境导出的dmp过大,但要求尽快导入至生产server,请网络室打通防火墙后发现測试网络为100M而生产网络贵为1000M却无法发挥不论什么作用即使通过networklin ...
- C#读取Word文档内容代码
首先要添加引用com组件:然后引用: using Word = Microsoft.Office.Interop.Word; 获取内容: /// /// 读取 word文档 返回内容 /// //// ...
- SDK目录结构和adb工具及命令介绍
1.SDK目录介绍: ******************************** add-ons:Android开发需要的第三方文件,附加的库,如Google APIs.GoogleMaps. ...
- Getting Started with the NDK
The Native Development Kit (NDK) is a set of tools that allow you to leverage C and C++ code in your ...
- retrofit2 okhttp3 RxJava butterknife 示例
eclipse的jar包配置 eclipse中貌似用不了butterknife buildToolsVersion "23.0.2" defaultConfig { applica ...
- 什么是mimeType?
因特网多媒体邮件扩展标示内容是什么格式.告诉浏览器或者server如何解析该数据http的请求和相应都含有一个mimeType字段 =>content-type(通用首部)
- 二、T4模板
上文带大家见识了下T4,这里呢开始介绍T4模板有关的内容.关于T4模板介绍和使用网上一搜一箩筐,想深入研究的可以自行去找些资料,这里只介绍接下来我们需要使用的一些知识,不会面面俱到的讲T4模板所有的知 ...
- Active控件有关问题
ActiveX 控件是允许网站提供视频等内容的网站. 当你浏览 Web 时,它们允许你使用工具栏.股票代号.视频和其它内容. 但是,这些程序有时可能出现问题,或者向你提供不需要的内容. 在某些情况下, ...
- 【BZOJ1010】玩具装箱
Description P教授要去看奥运,但是他舍不下他的玩具,于是他决定把所有的玩具运到北京.他使用自己的压缩器进行压缩,其可以将任意物品变成一堆,再放到一种特殊的一维容器中.P教授有编号为1... ...
- Tomcat部署多个项目及相关配置
1.配置多个项目 在tomcat的conf目录下,找到server.xml,在其中添加<Host>节点即可进行多个项目的部署 <Host name="localhost&q ...