Test instructions: Give you a large number, asking you to ask for less than half of this number and coprime with him.
How to solve the problem: the odd number is directly one-second, even less than half the maximum odd number.
Problem Solving Code:
1 //File name:a.cpp2 //Author:darkdream3 //Created time:2015 March 21 Saturday 23:08 24 seconds4 5#include <vector>6#include <list>7#include <map>8#include <Set>9#include <deque>Ten#include <stack> One#include <bitset> A#include <algorithm> -#include <functional> -#include <numeric> the#include <utility> -#include <sstream> -#include <iostream> -#include <iomanip> +#include <cstdio> -#include <cmath> +#include <cstdlib> A#include <cstring> at#include <ctime> - #defineLL Long Long - using namespacestd; - Charstr[2005]; - intnum[2005]; - intLen; in voidSolve () - { to for(inti =0; I <= Len; i++) +Num[i] = str[i]-'0'; - for(inti =0; I <= len/2; i + + ) the { *Swap (num[i],num[len-i]); $ }Panax Notoginseng } - voidChu () { the intTMP =0 ; + for(intI= Len; I >=0; I--) A { the intK = (TMP *Ten+num[i]); +Num[i] = k/2; -TMP = k%2; $ } $ if(Num[len] = =0 ) -Len-- ; - } the voidJian () { - for(inti =0; I <= len; i + +)Wuyi { the if(Num[i] = =0 ) -Num[i] =9; Wu Else{Num[i]-- ; - Break; About } $ } - if(Num[len] = =0) -Len-- ; - } A voidprint () + { the for(inti = len; I >=0; I--) - { $printf"%d", Num[i]); the } theprintf"\ n"); the } the intMain () { -Freopen ("china.in","R", stdin); inFreopen ("China.out","W", stdout); thescanf"%s", str); theLen =strlen (str); Aboutlen-- ; the solve (); the if(num[0] %2==1) the { + Chu (); - print (); the return 0 ; Bayi } the Chu (); the Jian (); - while(num[0]%2==0) - Jian (); the print (); the return 0; the}
View Code
AS1 A Chinese Girls ' Amusement