ACM ICPC Vietnam National Second Round D X = X + X % 100
来源:互联网 发布:程序员工具箱 编辑:程序博客网 时间:2024/04/29 03:30
//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); }}
0 0
- ACM ICPC Vietnam National Second Round D X = X + X % 100
- CF 2014 ACM-ICPC Vietnam National Second Round D. Treasure Box
- CF 2014 ACM-ICPC Vietnam National Second Round C. ATM withdrawal
- CF 2014 ACM-ICPC Vietnam National Second Round I. Space Tour
- ACM ICPC Vietnam National Second Round I. Space Tour(预处理 + 枚举)
- mysql 函数 --ROUND(X) ROUND(X,D)
- mysql的ROUND(X, D);ROUND(X)函数
- HDU 4734 F(x) 2013 ACM/ICPC 成都网络赛
- hdu4577 X-Boxes ACM-ICPC杭州赛区全国邀请赛 2
- x=x&(x-1)
- x=x&(x-1)
- x = x&(x-1)
- x = x&(x-1)
- Java x=x+(x++)+(++x)分析
- $X
- X
- X
- X
- 【CentOS 7】 单用户模式重置root密码
- MeanShift算法C++解析(四)
- 从“煎鸡蛋”到“孵小鸡”松下空调温暖呵护生命
- Action层, Service层 和 Dao层的功能区分
- Note-1-基本概念
- ACM ICPC Vietnam National Second Round D X = X + X % 100
- TC第一波:2015/11/3
- MeanShift算法C++解析(五)
- Leetcode || Letter Combinations of a Phone Number
- 云计算简介
- 【OpenCV人脸识别入门教程之三】CMake编译OpenCV源码
- DBCP连接池
- Hibernate一级缓存详解
- 巴氏距离实例