做了一天水题,挑几个还算凑合的发上来。

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 ;
}

POJ1207 The 3n + 1 problem

#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 ;
}

POJ2105 IP Address

#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 ;
}

POJ2499 Binary Tree

分析:

用减的话会超时的。用除省时间。

#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(全部水题)的更多相关文章

  1. poj 2105 IP Address(水题)

    一.Description Suppose you are reading byte streams from any device, representing IP addresses. Your ...

  2. 【转】POJ百道水题列表

    以下是poj百道水题,新手可以考虑从这里刷起 搜索1002 Fire Net1004 Anagrams by Stack1005 Jugs1008 Gnome Tetravex1091 Knight ...

  3. 【BZOJ】初级水题列表——献给那些想要进军BZOJ的OIers(自用,怕荒废了最后的六月考试月,刷刷水题,水水更健康)

    BZOJ初级水题列表——献给那些想要进军BZOJ的OIers 代码长度解释一切! 注:以下代码描述均为C++ RunID User Problem Result Memory Time Code_Le ...

  4. POJ 水题(刷题)进阶

    转载请注明出处:優YoU http://blog.csdn.net/lyy289065406/article/details/6642573 部分解题报告添加新内容,除了原有的"大致题意&q ...

  5. HDOJ 2317. Nasty Hacks 模拟水题

    Nasty Hacks Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Tota ...

  6. ACM :漫漫上学路 -DP -水题

    CSU 1772 漫漫上学路 Time Limit: 1000MS   Memory Limit: 131072KB   64bit IO Format: %lld & %llu Submit ...

  7. ytu 1050:写一个函数,使给定的一个二维数组(3×3)转置,即行列互换(水题)

    1050: 写一个函数,使给定的一个二维数组(3×3)转置,即行列互换 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 154  Solved: 112[ ...

  8. [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 ...

  9. gdutcode 1195: 相信我这是水题 GDUT中有个风云人物pigofzhou,是冰点奇迹队的主代码手,

    1195: 相信我这是水题 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 821  Solved: 219 Description GDUT中有个风云人 ...

随机推荐

  1. XML转义特殊字符

    正常来说,只有"<" 字符和"&"字符对于XML来说是严格禁止使用的. 需要注意的是: a. 转义序列各字符间不能有空格: b. 转义序列必须以& ...

  2. [Angular 2] Controlling how Styles are Shared with View Encapsulation

    Style and View Encapsulation is best understood by seeing how each option (Emulated, Native, and Non ...

  3. [Falcor] Indroduce to Model

    How to work with JSON data indirectly through a Falcor Model. The Falcor Model allows you to work wi ...

  4. Content Provider Basics ——Content Provider基础

    A content provider manages access to a central repository of data. A provider is part of an Android ...

  5. HDU -2298 Toxophily(三分法)

    这道题目,可以推出物理公式直接来做,但是如果推不出来就必须用程序的一种算法来实现了,物理公式只是适合这一个或者某个题,但是这种下面这种解决问题的方法确实解决了一类问题 ----三分法,大家可能都听说过 ...

  6. python面对对象编程---------6:抽象基类

    抽象基本类的几大特点: 1:要定义但是并不完整的实现所有方法 2:基本的意思是作为父类 3:父类需要明确表示出那些方法的特征,这样在写子类时更加简单明白 用抽象基本类的地方: 1:用作父类 2:用作检 ...

  7. html.day02

    1.链接标签  a <a href=”http://www.baidu.com”></a> <img src=”aaa”/> 一般情况下:  来源  用 src   ...

  8. 安装ZendDebugger 调试php

    一直懒得装断点调试工具,平时调试就用echo var_dump debug_print_backtrace 搞搞. 今天同事装了个xdebug,看着眼馋.于是想自己也装一个,由于平时用zend stu ...

  9. 对exp full 和 imp full的认识

    前段时间听同事说.Toad 工具可以打开 oracle数据库的 .dmp 文件.今天抽空试了试,果然可以!Oracle 执行 export 操作 会把 表的定义导出.表的数据导出. 其实 .dmp 文 ...

  10. iOS和hybird移动端性能

         作为一名写了⑦年代码的程序员,目前我最擅长的领域是IOS的客户端开发,在移动领域的开发时间2年. ⑦年前,我刚入行的时候,曾经认为自己将会永远做一个LINUX 服务端C++程序员,于是花了大 ...