Description

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

  1001
+ 1101
-------
0100

You see, everything is like an addition, except that there are no carries.

After realizing this, Pangzi invented Super XOR. It is just an 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 <= 1000), indicating the number of test cases.

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

Output Format

Output T lines, each line is an integer: the answer for the corresponding test case.

Sample Input

5
1
2
3
4
120001

Sample Output

1
3
6
0
240001

Case Limits

Time limit: 500 msec

Memory limit: 64 MB

一开始读错题了..这都能读错 也是没谁了。

就是求1~n这些数的和 不进位。难度不大。但注意细节,思路一定要清晰。否则无限tle  无限re

思路:打表发现末尾是99的 结果是0 那么找到比n小的末尾是99的 对***99~n 求其和就行了。

/* ***********************************************
Author :guanjun
Created Time :2016/3/12 9:39:27
File Name :sjtu1201.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>
#define ll long long #define mod 90001
#define INF 0x3f3f3f3f
#define maxn 10010
#define cle(a) memset(a,0,sizeof(a)) const double eps=1e-;
using namespace std; int ar[],num;
void add(ll x){
num=;
while(x>){
ar[num]+=(x%);
ar[num]%=;
x/=;
num++;
}
}
int main()
{
#ifndef ONLINE_JUDGE
freopen("in.txt","r",stdin);
#endif
//freopen("out.txt","w",stdout);
int t;
ll n,k,m;
cin>>t;
while(t--){
cin>>n;
m=n;
cle(ar);
if(n>){
while(){
if(n%==){
k=n+;
break;
}
n--;
}
for(ll i=k;i<=m;i++)add(i);
}
else for(ll i=;i<=n;i++)add(i);
ll ans=;
ll tmp=;
for(int i=;i<num;i++){
ans+=ar[i]*tmp;
tmp*=;
}
cout<<ans<<endl;
}
return ;
}

最新文章

  1. shell 中的与、或表达式
  2. iMac 升级到10.12后,蓝牙不能用
  3. thinkphp 完整配置config.php
  4. reader
  5. Service Station - An Introduction To RESTful Services With WCF
  6. httpclient 认证方式访问http api/resutful api并获取json结果
  7. BZOJ-1975 魔法猪学院 K短路 (A*+SPFA)
  8. C#和ASP.Net面试题目集锦
  9. 12 为何使用Html5+CSS3
  10. dubbo简述
  11. 让你的WizFi250适应各种气候
  12. Redis进阶实践之二如何在Linux系统上安装安装Redis
  13. centos7设置httpd
  14. HTML&amp;CSS总结
  15. Apache Tomcat RCE(CVE-2017-12615 )漏洞案例分析
  16. 解决同一activity下多个fragment 切换时重复执行onCreateView方法
  17. vs2015添加管理员权限
  18. python3笔记(二)Python语言基础
  19. mysql性能分析show profile/show profiles
  20. PAT——1037. 在霍格沃茨找零钱

热门文章

  1. [USACO5.3]Big Barn (动态规划)
  2. 什么是JNI?
  3. Codeforces891C. Envy
  4. MongoDB_起步
  5. Xcode打包应用为ipa
  6. Linux 下MySQL 安装与卸载
  7. JFinal2.0极速开发视频教程发布【转】
  8. 安装Django时解决的问题-mysql及访问(附pycharm激活)
  9. 解决maven无法下载依赖的jar包的问题
  10. DELPHI方法注释的标准写法