SJTU OJ 1201. Superxor

Source: Internet
Author: User

Description

Pangzi recently realized that bitwise XOR operation was just an addition without carries. For example, when computing (1001) _2 XOR (1101) _2, you write down:

  1001+ 1101-------  0100

Everything is a addition, except that there is no carries.

After realizing this, Pangzi invented Super XOR. It is just a addition on decimal numbers without carries. For example, 123 superxor 789 = 802, since 1+7=8, 2+8=0, 3+9=2.

Now comes a question. Given N, find 1 Superxor 2 superxor 3 Superxor 4 superxor ... Superxor N

Input Format

The first line contains an integer t (1 <= t <=), indicating the number of test cases.

T lines follow each containing 1 integers n (1 <= n <= 10^12).

Output Format

Output T lines, each of which is a integer:the answer for the corresponding test case.

Sample Input
51234120001
Sample Output
1360240001
Case Limits

Time limit:500 msec

Memory limit:64 MB

I read the wrong question at first. There's no one who can read it wrong.

is to ask 1~n these numbers and not carry them. Not very difficult. But attention to detail, the idea must be clear. Otherwise infinite tle infinite re

Idea: Hit the table found at the end is 99 of the result is 0 then find than n small end is 99 of the ***99~n to ask for it and on the line.

/************************************************author:guanjuncreated TIME:2016/3/12 9:39:27File name:s jtu1201.cpp*************************************************/#include<iostream>#include<cstring>#include<cstdlib>#include<stdio.h>#include<algorithm>#include<vector>#include<queue>#include<Set>#include<map>#include<string>#include<math.h>#include<stdlib.h>#include<iomanip>#include<list>#include<deque>#include<stack>#definell Long Long#defineMoD 90001#defineINF 0x3f3f3f3f#defineMAXN 10010#defineCLE (a) memset (A,0,sizeof (a))Const Doubleeps=1e-5;using namespacestd;intar[ -],num;voidAdd (ll x) {num=0;  while(x>0) {Ar[num]+ = (xTen); Ar[num]%=Ten; X/=Ten; Num++; }}intMain () {#ifndef Online_judge freopen ("In.txt","R", stdin); #endif    //freopen ("OUT.txt", "w", stdout);    intT;    ll N,k,m; CIN>>T;  while(t--) {cin>>N; M=N;        CLE (AR); if(n> About){             while(1){                if(n% -== About) {k=n+1;  Break; } N--; }             for(LL i=k;i<=m;i++) Add (i); }        Else  for(LL i=1; i<=n;i++) Add (i); ll ans=0; LL TMP=1;  for(intI=0; i<num;i++) {ans+=ar[i]*tmp; TMP*=Ten; } cout<<ans<<Endl; }    return 0;}

SJTU OJ 1201. Superxor

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.