U6850 Phone PasswordTopic Background
Xiao Ming's phone set up a four-digit password, but Xiao Ming's own memory is not good, but do not want to put the password directly on the paper, so he thought of a method.
Title Description
Xiao Ming has four lines of numbers, each line of numbers have n[i] (<=250) bit, the number of the first line represents the first bit of Xiao Ming password, Xiao Ming password conversion method is this: Add this number of people on the number, you will get a new number, repeat this operation until the new number is less than 10.
N[i] not in input
input/output formatInput Format:
A total of four rows, one number per line.
output Format:
A number that represents Xiaoming's four digit password.
input/Output sampleInput Sample # #:
123456789325633432633426452634654
Sample # # of output:
9292
Description
123456789=1+2+3+4+5+6+7+8+9=45=4+5=932563343=3+2+5+6+3+3+4+3=29=2+9=11=1+1=226334=2+6+3+3+4=18=1+8+926452634654=2+6+4+5+2+6+3+4+6+5+4=47=4+7=11=1+1=2
Password =9292
Note: Do not want to use Int64 (long long) cheat points, real data in n[i] at least one will >20.
There are 2 n[4]<1 in the data. Do not know how Lo evaluation
#include <iostream>#include<cstdio>#include<cstring>#include<algorithm>using namespacestd;Chars[5][251];Long Longnum;intans[5];intMain () { for(intI=1; i<=4; i++) cin>>S[i]; for(intI=1; i<=4; i++) {num=0; intlen=strlen (S[i]); for(intj=0; j<len;j++) Num+=s[i][j]-'0'; while(num>9){ Long Longx=num;num=0; while(x) {num+=x%Ten; X/=Ten; }} Ans[i]=num; } for(intI=1; i<=4; i++) cout<<ans[i];}
Rokua U6850 Phone Password