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

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. Leetcode - Reverse Words

    比起POJ弱爆了一题,从后往前扫描一遍,O(n)时间,仅仅要注意各种极端情况就可以,不明确通过率为什么仅仅有13%. #include<iostream> #include<stri ...

  2. cocos2d-x3.0 Physics新的物理引擎

    1.说明: 3.0以后将box2d和chipmunk这两个物理引擎进行了封装,使用起来很的便利 2.详细用法: 1.创建物理世界场景 auto scene = Scene::createWithPhy ...

  3. Git客户端(Windows系统)的使用

    本文环境: 操作系统:Windows XP SP3 Git客户端:TortoiseGit-1.8.5.0-32bit 一.安装Git客户端 全部安装均采用默认! 1. 安装支撑软件 msysgit:  ...

  4. 汉诺塔III 递推题

    题目描述: 约19世纪末,在欧州的商店中出售一种智力玩具,在一块铜板上有三根杆,最左边的杆上自上而下.由小到大顺序串着由64个圆盘构成的塔.目的是将最左边杆上的盘全部移到右边的杆上,条件是一次只能移动 ...

  5. Android开发艺术探索》读书笔记 (8) 第8章 理解Window和WindowManager

    第8章 理解Window和WindowManager 8.1 Window和WindowManager (1)Window是抽象类,具体实现是PhoneWindow,通过WindowManager就可 ...

  6. Python开发【第八篇】:网络编程

    Python之路[第六篇]:socket   Socket socket通常也称作"套接字",用于描述IP地址和端口,是一个通信链的句柄,应用程序通常通过"套接字&quo ...

  7. 各浏览器对 onbeforeunload 事件的支持与触发条件实现有差异

    转载:http://www.w3help.org/zh-cn/causes/BX2047 标准参考 无. 问题描述 一般情况下,onbeforeunload 事件处理函数内会写入一些提示性语句,当用户 ...

  8. Smarty的配置与高级缓存技术

    转之--http://www.cnblogs.com/-run/archive/2012/06/04/2532801.html Smarty 是一个出色的PHP模板引擎,它分离了逻辑代码和user i ...

  9. Android设计图(标注、切图)

    1.Android: 1)Android的单位是dp 2)分为ldpi/mdpi/hdpi/xhdpi/xxhdpi. 3)分辨率对应DPI ldpi  QVGA (240×320) mdpi  HV ...

  10. (一)SAPI简述

    SAPI,软件中的语音技术包括两方面的内容,一个是语音识别(speech recognition) 和语音合成(speech synthesis).这两个技术都需要语音引擎的支持. 下面我们来了解下基 ...