ZOJ 3591 & 3594
2013-04-07 21:12
323 查看
3591 Nim
这题连基本的Nim都不告诉怎么,让比赛时没见过的情何以堪。
3594 Sexagenary Cycle
公元不是从零年开始的,莫不是因为那时没有计算机。
3695 Two Sequences
原来只差一次求导,启蒙时没学过级数确实不够敏锐啊。
这题连基本的Nim都不告诉怎么,让比赛时没见过的情何以堪。
#include <cstdio> #include <algorithm> using namespace std; typedef long long ll; int T, N, S, W; int a[1000001]; inline void Generate() { int g = S; ++ N; for(int i=1; i<N; ++i) { a[i] = g; if( a[i] == 0 ) a[i] = g = W; a[i] ^= a[i-1]; if( g%2 == 0 ) g = g / 2; else g = (g / 2) ^ W; } } int main() { scanf("%d", &T); while(T --) { scanf("%d%d%d", &N, &S, &W); ll sum = N*(N+1ll)/2; Generate(); sort(a+1, a+N); S = 1; for(int i=2; i<N; ++i) { if(a[i] == a[i-1]) ++S; else { if(a[i-1]==0) sum -= S; sum -= S*(S-1ll)/2; S = 1; } } sum -= S*(S-1ll)/2; printf("%lld\n", sum); } return 0; }
3594 Sexagenary Cycle
公元不是从零年开始的,莫不是因为那时没有计算机。
#include <iostream> #include <string> using namespace std; const string h[10] = { "Jia", "Yi", "Bing", "Ding", "Wu", "Ji", "Geng", "Xin", "Ren", "Gui"}; const string e[12] = { "zi", "chou", "yin", "mao", "chen", "si", "wu", "wei", "shen", "you", "xu", "hai"}; int main() { int T, year; cin >> T; while(T --) { cin >> year; if(year < 0) year += 1; if(year >= 1911) { cout << h[(year-1911+7)%10]; cout << e[(year-1911+11)%12]; cout << endl; } else { year = 1911 - year; cout << h[(17-year%10)%10]; cout << e[(23-year%12)%12]; cout << endl; } } return 0; }
3695 Two Sequences
原来只差一次求导,启蒙时没学过级数确实不够敏锐啊。
相关文章推荐
- Penney's game (hdu 5169, zoj 3274)
- zoj 2475 Benny's Compiler
- zoj 2965 Accurately Say "CocaCola"!
- UVa 439/HDU 1372/POJ 2243/ZOJ 1091 Knight Moves(BFS&纯数学方法)
- ZOJ 3547 & HDU 4059
- ZOJ 4772 Treasure Hunt I 树形DP(背包) && hdu The Ghost Blows Light 树形DP(背包)
- ZOJ 3736 & HDU 4801 - Pocket Cube 打表搜索
- hdu 1045 && zoj 1002 Fire Net(DFS && 二分图匹配)
- ZOJ1221 && UVA567:Risk(Floyd)
- zoj 2734 Exchange Cards(母函数 && DFS)
- STL-ZOJ-2829 Beautiful Number:打表的艺术&&map映照容器
- zoj 1951 || poj 2262 Goldbach's Conjecture(水水~)
- ZOJ 3988 && 2017CCPC秦皇岛 H:Prime Set(二分匹配)
- zoj 1383 Binary Numbers&&zoj 1491 Climbing Worm(简单)
- zoj 3633 Alice's present
- zoj 1395 && poj 1300 Door Man
- zoj 3594 Sexagenary Cycle(模拟)
- zoj 1813 Biker's Trip Odometer
- POJ 2546 & ZOJ 1597 Circular Area(求两圆相交的面积 模板)
- ZOJ 3569 Dr. Zomboss's Revenge(贪心)