HDU 5832A water problem 简单模拟
来源:互联网 发布:centos 7 1611下载 编辑:程序博客网 时间:2024/05/20 14:40
看题可以容易知道给定的数得是10001的倍数
n 必须用字符串储存,然后模拟减去10001 再除10,继续重复这个步骤
#include <iostream>#include <algorithm>#include <cmath>#include <cstring>#include <string>#include <vector>#include <map>#include <cstdio>#include <cstdlib>using namespace std;const int maxn = 10000000 + 7;char s[maxn];int a[maxn];void solve(){ int n = strlen(s); for(int i = 0; i < n; i++) { a[i] = s[i] - '0'; } for(int i = n - 1; i - 4 >= 0; i--) { int j = i - 4; a[j] -= a[i]; a[i] -= a[i]; while(a[j] < 0 && j < n) { a[j] += 10; a[j - 1]--; j++; } }**HDU 5832 A water problem** for(int i = 0; i < n; i++) { if(a[i] != 0) { cout << "NO" << endl; return ; } } cout << "YES" << endl;}int main(){ int cases = 0; while(~scanf("%s", s)) { printf("Case #%d: ", ++cases); solve(); memset(a, 0, sizeof(a)); memset(s, 0, sizeof(s)); } return 0;}
阅读全文
0 0
- HDU 5832A water problem 简单模拟
- hdu 5832 A water problem
- HDU 5832 A water problem
- hdu 5832 A water problem
- HDU 5832 A water problem
- HDU 5832 A water problem
- HDU 5832 A water problem
- hdu 5832 A water problem(简单数论)
- HDU 4974 A simple water problem 模拟(水
- HDU 5832 A water problem (水题)
- HDU 5832 A water problem【大数问题】
- HDU 5832 A water problem(水~)
- HDU-5867 Water problem(模拟)
- HDU 5832 A water problem(简单思维题目)【2016中国大学生程序设计竞赛 - 网络选拔赛】
- 【2016-CCPC-A】水题(A water problem,hdu 5832)
- HDU 5867 Water problem (模拟)
- HDU 5867 Water problem——模拟
- hdu 5832 A water problem 2016icpc网络赛
- 查看RHEL网卡绑定模式和绑定状态
- 状态位
- 【怎样写代码】确保对象的唯一性 -- 单例模式(四):饿汉式单例类与懒汉式单例类的讨论
- 设置Activity无标题栏
- Android 获取APK编译时间
- HDU 5832A water problem 简单模拟
- listagg函数将查询列转为行
- 类文件结构
- POJ-2528Mayor's posters(离散+线段树区间覆盖)
- URL(字符串)
- [BZOJ3395]回文串
- leetcode--84. Largest Rectangle in Histogram
- 安装samba
- MATLAB中文件的读写和数据的导入导出【转】