Link: pku1047 hdu1313 tzc1086
Method: multiply a large number by a decimal number
Code:
// Tzc1086 hdu1313 // note the difference between string and cstring // The string class defines mainly Operator overloading, // while the cstring class is equivalent to string. h. It contains strlen functions # include <iostream> # include <cstring> # include <vector> # include <string> using namespace STD; void mult (char C [], char T [], int m) {int I, L, K, flag, add = 0; char s [100]; L = strlen (C ); for (I = 0; I <L; I ++) s [l-i-1] = C [I]-'0'; for (I = 0; I <L; I ++) {k = s [I] * m + Add; If (k> = 10) {s [I] = K % 10; add = K/10; flag = 1 ;}else {s [I] = K; flag = 0; add = 0 ;}} if (FLAG) {L = I + 1; s [I] = add;} else l = I; for (I = 0; I <L; I ++) T [l-1-i] = s [I] + '0'; t [l] = '\ 0';} void change (char * s) {char TMP = s [0]; int I; for (I = 1; I <strlen (s); I ++) s [I-1] = s [I]; s [I-1] = TMP; s [I] = '\ 0';} int main () {char STR [80], TMP [80]; while (CIN> Str) {cout <STR; strcpy (TMP, STR); vector <string> V; string s; int I, j; for (I = 0; I <strlen (STR); I ++) {change (TMP); s = TMP; V. push_back (s);} Char res [80]; string t; for (I = 1; I <= strlen (STR); I ++) {mult (STR, res, i); t = res; For (j = 0; j <v. size (); j ++) {If (t = V [J]) break;} If (j = v. size () break;} if (I> strlen (STR) cout <"is cyclic" <Endl; else cout <"is not cyclic" <Endl;} return 0 ;}