AS1 A Chinese Girls ' Amusement

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.