UVALive - 4868 暴力
2017-05-13 18:02
337 查看
老铁,这个题把就别想啥算法了,直接暴力秒了做下题吧,一开始还在想什么算法,后来一看数据直接不忍了,给个小数据简直了,暴力了。
#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; int huiwen(char s[]){ int len = strlen(s); int min = len / 2; int flag = 1; for(int i=0;i<min;i++){ if(s[i]!=s[len-1-i]){ flag = 0; } } return flag; } int main(){ char s[10]; while(scanf("%s",&s) && strcmp("0",s) != 0){ long long num = 0; if(!huiwen(s)){ int len = strlen(s); while(true){ for(int i = len-1; i >= 0; i--){ if(s[i]!='9'){ s[i] = s[i] + 1; break; }else{ s[i] = '0'; } } num++; if(huiwen(s)){ break; } } } printf("%lld\n",num); } }
相关文章推荐
- UVALive 4868 Palindrometer 暴力
- UVALive 6319 暴力
- uvaLive 3401 Colored Cubes 暴力
- UVALive2953 POJ1775 ZOJ2358 Sum of Factorials【打表+暴力+水题】
- UVALive 7672 - What a Ridiculous Election (暴力)
- UVALive - 4253 Archery 暴力
- UVALive-7279 - Sheldon Numbers(暴力大法)
- UVALive 7279 Sheldon Numbers (暴力打表)
- UVALive 6912 Prime Switch 暴力枚举+贪心
- HDU1334 ZOJ1331 UVA386 UVALive5303 Perfect Cubes【暴力】
- UVALive 6893 The Big Painting(二维hash,暴力)
- UVALive - 4979 Game 暴力|模拟|签到
- 【暴力】UVALive - 4882 - Parenthesis
- UVALive 4764 简单dp水题(也可以暴力求解)
- UVALive 6862 Triples (找规律 暴力)
- Robot Race UVALive - 7020几何暴力
- UVALive 6855 Banks (暴力)
- UVALive 6924 暴力
- UVALive 6659 Dromicpalin Substrings (递推 + 暴力枚举)
- Banks UVALive - 6855 (暴力)