uva 1583 B - Digit Generator (暴力)
2015-09-15 17:28
274 查看
B - Digit Generator
Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %llu
Submit Status
Description
View Code
Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %llu
Submit Status
Description
/************************************************************************* > File Name: code/uva/1583.cpp > Author: 111qqz > Email: rkz2013@126.com > Created Time: 2015年09月15日 星期二 16时47分20秒 ************************************************************************/ #include<iostream> #include<iomanip> #include<cstdio> #include<algorithm> #include<cmath> #include<cstring> #include<string> #include<map> #include<set> #include<queue> #include<vector> #include<stack> #include<cctype> #define y1 hust111qqz #define yn hez111qqz #define j1 cute111qqz #define ms(a,x) memset(a,x,sizeof(a)) #define lr dying111qqz using namespace std; #define For(i, n) for (int i=0;i<int(n);++i) typedef long long LL; typedef double DB; const int inf = 0x3f3f3f3f; int n ; bool judge(int x,int y) { int r; int sum = 0; int tmp = y-x; while (x) { r = x % 10; x = x/10; sum = sum + r; } if (sum==tmp) return true; return false; } int main() { #ifndef ONLINE_JUDGE freopen("in.txt","r",stdin); #endif int T; cin>>T; while (T--) { scanf("%d",&n); int ans = 0 ; int st = n-54; for ( int i = st ; i <= n ;i++) { if (judge(i,n)) { ans = i; break; } } printf("%d\n",ans); } #ifndef ONLINE_JUDGE fclose(stdin); #endif return 0; }
View Code
相关文章推荐
- 不要你动手
- Win8系统文件损坏,无法自动修复的解决方法
- Struts 2 – i18n or localization example
- oracle 索引概述
- java第一个窗口
- 命令行调用code sign时报错:User interaction is not allowed
- TNS-12560/00350 协议适配器错误
- 89 php 登陆验证
- Gradle, 基于DSL的新一代Java构建工具
- iOS 增加UIButton按钮的可点击区域
- Ponds
- DNS服务器的搭建
- android【采用pull解析xml文件】
- GUID和INT两种数据类型做主键的比较
- flume将日志到hive实现
- jqGrid colModel 中colModel 后台生成传入前端,实现jqGrid 动态列
- (转)OSI七层模型详解
- linux命令行计算器
- openssl简易文档
- session 学习-为登录添加验证码