ACM ICPC Vietnam National Second Round D X = X + X % 100
2015-11-03 21:32
375 查看
// ACM ICPC Vietnam National Second Round D // // 题目大意: // // X = X + X % 100.给你一个N和K.求K次操作后N的值 // // 解题思路: // // 看到N和K都是1e9这种数.想到肯定会有循环节.然后 // 打表找规律.一开始发现是20一循环.即4的倍数才可以开 // 始循环,然而太年轻,交了无数发,wrong了无数发.后来发现 // 10这类的也是有循环4一循环.欣喜的敲了一发,然后还是wrong // 这时候,我又想到了00这种特殊的情况,好,又交,又wrong // 当然50也要特判啊.25啊,75啊都特判.写完之后,我发现自己太 // 年轻了,这样就可以过了.还是自己考虑问题不够周全吧. // 情况多多,做练习赛的时候并没有做出来.不得不说自己太弱了. // 继续加油,FIGHTING!!! #include <cstring> #include <algorithm> #include <iostream> #include <cstdio> #include <cmath> #include <string> #include <vector> #include <queue> #define For(x,a,b,c) for (int x = a; x <= b; x += c) #define Ffor(x,a,b,c) for (int x = a; x >= b; x -= c) #define cls(x,a) memset(x,a,sizeof(x)) using namespace std; typedef long long ll; const int MAX_N = 108; const int INF = 0x3f3f3f3f; const ll MOD = 1e6; ll N,K; int a[108]; int cnt[108]; bool vis[108]; int main(){ // cls(a,0); //打表所用 // cls(cnt,0); // for (int i = 1 ;i < 100;i ++){ // cls(vis,0); // int k = 0; // vis[i] = 1; // int x = i; // x = x + x % 100; // int t = x % 100; // int c = 1; // while(!vis[t]){ // vis[t] = 1; // x = x + x % 100; // t = x % 100; // c++; // } // a[i] = x; // cnt[i] = c; // // if (i % 10 == 5) // // printf("%d %d %d\n",i,x,c); // } //freopen("1.in","r",stdin); int kase; scanf("%d",&kase); for (int i = 1;i <= kase ;i ++){ scanf("%I64d%I64d",&N,&K); ll ans = N / 100 * 100; ll res = N % 100; if (res == 0){ printf("%I64d\n",N); continue; } if ( res == 50){ printf("%I64d\n", N + 50); continue; } if ( res == 25){ if (K >= 1000000){ printf("%I64d\n",ans + 100); } continue; } if (res == 75){ if (K >= 1000000){ printf("%I64d\n",ans + 200); } continue; } if (K < 1000000){ for (int j = 1;j <= K;j ++){ res = res + res % 100; } printf("%I64d\n",ans + res); continue; } int c = 0; if ( res % 10 != 0 || res % 10 != 5){ while((res % 100) % 4){ res += res % 100; c++; } K -= c; res = res + K / 20 * 1000; K %= 20; } else { while(((res % 100) / 10) % 2){ res += res % 100; c++; } K -= c; res = res + K / 4 * 200; K %= 4; } for (int j = 0 ; j < K; j++){ res += res % 100; } printf("%I64d\n",ans + res); } }
相关文章推荐
- Linux下XWindow图形界面的基本概念
- 什么是Mac OS X?跟Linux有什么区别
- 实用的利用 CSS + <em>标签 来完成一个三角形的制作
- JavaScript中“+”的陷阱深刻理解
- clientX,pageX,offsetX,x,layerX,screenX,offsetLeft区别分析
- AJAX 请求区分 $_SERVER['HTTP_X_REQUESTED_WITH'] 小解
- ASP + Serv-u 实现FTP的代码
- css静态滤镜 + A:Hover 效果第1/3页
- FreeBSD5.4Release X Windows 安装笔记 (Freebsd5.4R+Gnome2.10.0)
- javascript中加号(+)操作符的一些神奇作用
- iOS、Mac OS X系统中编程实现汉字转拼音的方法(超级简单)
- Python列表append和+的区别浅析
- windows+ubuntu双系统重新安装windows后的引导修复 3ff0
- OS X Mavericks 10.9.2 Retail VMware Image
- Mac OS X 背后的故事(二)——Linus Torvalds的短视
- Mac OS X 背后的故事(四)—— 政客的跨界
- XBMC on ATV2 + XBMoteC(remote app)[XBMC遠端遙控器]
- 从进程PID查找X Window ID
- Spring + Struts2 + Hibernate整合
- postfix + amavisd-new + clamav + spamassassin