HDU 2608 : 0 or 1 ( 数论)
Solving problem is a interesting thing. DragonLee like to slove different problembecause he think it is a way let him more intelligent. But as we knowDragonLee is weak in math. When he come up against a difficult math problem he always try to get a hand.
Now the problem is coming! Let we define T(n) as the sum of all numbers which are positive integers can divied n. and S(n) = T(1) + T(2) + T(3)+...+T(n).
Input
The first line of the input contains an integer T which means the number of test cases. Then T lines follow each line consists of only one positive integers n. You may assume the integer will not exceed 2^31.
Output
For each test case you should output one lines of one integer S(n) %2. So you may see the answer is always 0 or 1 .
Sample Input
copy
3 1 2 3
Sample Output
copy
1 0 0
HINT
S(3) = T(1) + T(2) +T(3) = 1 + (1+2) + (1+3) = 8
S(3) % 2 = 0
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cstdio>
#include <set>
#include <math.h>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <ctime>
#define ind 0x3f3f3f3f
#define ll long long
using namespace std;
const int mxn = 1e6;
int n,m,k,ans,cnt,cs,a[mxn];
int main()
{
ll col;
cin>>n;
while(n--)
{
cin>>col;
cout<< ( (int)sqrt(col*1.0)%2 + (int)sqrt(col/2.0)%2 )%2<<endl;
}
return 0;
}
原文地址:https://www.cnblogs.com/Shallow-dream/p/11837771.html
- JavaScript 教程
- JavaScript 编辑工具
- JavaScript 与HTML
- JavaScript 与Java
- JavaScript 数据结构
- JavaScript 基本数据类型
- JavaScript 特殊数据类型
- JavaScript 运算符
- JavaScript typeof 运算符
- JavaScript 表达式
- JavaScript 类型转换
- JavaScript 基本语法
- JavaScript 注释
- Javascript 基本处理流程
- Javascript 选择结构
- Javascript if 语句
- Javascript if 语句的嵌套
- Javascript switch 语句
- Javascript 循环结构
- Javascript 循环结构实例
- Javascript 跳转语句
- Javascript 控制语句总结
- Javascript 函数介绍
- Javascript 函数的定义
- Javascript 函数调用
- Javascript 几种特殊的函数
- JavaScript 内置函数简介
- Javascript eval() 函数
- Javascript isFinite() 函数
- Javascript isNaN() 函数
- parseInt() 与 parseFloat()
- escape() 与 unescape()
- Javascript 字符串介绍
- Javascript length属性
- javascript 字符串函数
- Javascript 日期对象简介
- Javascript 日期对象用途
- Date 对象属性和方法
- Javascript 数组是什么
- Javascript 创建数组
- Javascript 数组赋值与取值
- Javascript 数组属性和方法
- 『爬虫四步走』手把手教你使用Python抓取并存储网页数据!
- 快速掌握并发编程---synchronized篇(下)
- pivottablejs|在Jupyter中尽情使用数据透视表!
- 快速掌握并发编程---锁优化篇
- 弄懂这 6 个问题,拿下 Python 生成器!
- 快速掌握并发编程---线程阻塞与唤醒
- DOM优化之重绘和回流
- 本地储存之 Cookie、webStorage、indexedDB
- 使用DocumentFragment优化DOM操作
- 事件的防抖和节流
- JS事件循环之宏任务和微任务
- 小程序生成图片并保存
- 快速掌握接口测试利器Postman
- 小程序中使用less
- 快速学习多协议抓包利器Wireshark