codeforces 808A Lucky Year
来源:互联网 发布:艾宾浩斯记忆软件 编辑:程序博客网 时间:2024/05/21 21:45
#include<iostream>#include<vector>#include<string>#include<set>#include<map>#include<algorithm>#include<queue>#include<list>#include<stack>#include<cstdio>#include<fstream>#include<numeric>#include<functional>#include<utility>#include<memory>using namespace std;string year;//900000000//1000000000long int sub(string first, string second){if (second.size() == 1) return 1;long int t = 1;long int res = 0;if (first.size() > second.size()){bool flag = true;string temp(second.size(), '9');for (int i = second.size() - 1; i >= 0; i--){res += (9 - (second[i] - '0'))*t;t *= 10;}res += 1;return res;}for (int i = first.size() - 1; i > 0; i--){if (t == 1){res += (10 - (second[i] - '0'))*t;}else{res += (9 - (second[i] - '0'))*t;}t = t * 10;}return res;}int main(){while (cin >> year){int length = year.length();string temp(length, '0');if (year[0] == '9'){temp.insert(temp.begin(), '1');}else{temp[0] = (year[0] - '0') + 1 + '0';}long int res = sub(temp, year);cout << res << endl;}return 0;}
阅读全文
0 0
- codeforces 808A Lucky Year
- 【Codeforces 808 A. Lucky Year】
- Codeforces 808A Lucky Year 题解
- 【Codeforces 808A】【模拟】Lucky Year 题解
- CodeForces 808A Lucky Year(思维)
- 808A Lucky Year
- Educational Codeforces Round 21 808A Lucky Year
- codeforces——808A——Lucky Year
- Educational Codeforces Round 21 A. Lucky Year
- Educational Codeforces Round 21 A. Lucky Year
- Educational Codeforces Round 21 A. Lucky Year
- codecodefor 808A——Lucky Year
- CF#808 A. Lucky Year(水题)
- A. Lucky Year
- CodeForces 808A——Lucky Year——思维,模拟
- 【CodeForces】A. Lucky Division
- CodeForces 122A Lucky Division
- CodeForces 122A Lucky Division
- mysql的记录
- 数据结构四双向链表
- 关于实训周记
- android中通过GET方法接收数据并通过xml解析数据,POST方法向服务器提交数据
- HDOJ 1013
- codeforces 808A Lucky Year
- Java Set集合使用方法介绍(1)——在集合中插入字符串
- jsp内置对象
- HDOJ 1012
- 翻硬币
- springmvc+mybatis+redis的maven项目
- Linux- 一-软件安装-(20170512)
- HDOJ 1008
- VIM: 统计