2017 ACM-ICPC 亚洲区(西安赛区)网络赛C. Sum【脑洞题】
限制:1000ms 32768K
Define the function S(x) for xx is a positive integer. S(x) equals to the sum of all digit of the decimal expression of x. Please find a positive integer k that S(k∗x)%233=0.
Input Format
First line an integer T, indicates the number of test cases (T≤100). Then Each line has a single integer x(1≤x≤1000000) indicates i-th test case.
Output Format
For each test case, print an integer in a single line indicates the answer. The length of the answer should not exceed 2000. If there are more than one answer, output anyone is ok.
样例输入
1
1
样例输出
89999999999999999999999999
看来脑洞不够大。。。。
方法一:直接输出233个9。因为任何正整数乘以9的数位和都是9的倍数。。。
#include <iostream>
using namespace std; int main()
{
int T,n;
cin>>T;
while(T--){
cin>>n;
for(int i=;i<=;i++){
cout<<;
}
cout<<endl;
}
return ;
}
方法二:
当x<10时可以直接输出233个x,当1000>x>=10时,不妨设k*x=233个x,那么k=10(233个10),当1000<=x<10000,k=100(233个100),等等。手动模拟一下就懂了。
#include <iostream>
using namespace std; int main()
{
int T,n;
cin>>T;
while(T--){
cin>>n;
int tmp=n;
int len=;
while(n){
len++;
n/=;
} if(len==){
for(int i=;i<;i++)
cout<<tmp;
}else if(len==){
for(int i=;i<;i++)
cout<<"";
}else if(len==){
for(int i=;i<;i++)
cout<<"";
}else if(len==){
for(int i=;i<;i++)
cout<<"";
}else if(len==){
for(int i=;i<;i++)
cout<<"";
}else{
for(int i=;i<;i++)
cout<<"";
}
cout<<endl;
}
return ;
}
最新文章
- C语言-自定义函数
- Java 设计模式之代理模式
- ionic的scroll的使用出现的问题
- 使用php递归计算目录大小
- mysql union和union all
- CGlib使用案例
- WIN7 Wireshark: There are no interfaces on which a capture can be done
- IPSec VPN实验
- C# 委托的理解
- Object-C 里面的animation动画效果,核心动画
- Bilibili/DanmakuFlameMaster: Android开源弹幕引擎&#183;烈焰弹幕使 ~ JNI source:Bilibili/NativeBitmapFactory
- SuperSocket基础二
- May 24. 2018 Week 21st Thursday
- 洛谷P3222 [HNOI2012]射箭(计算几何,半平面交,双端队列)
- mongodb中投票节点作用
- svn Advanced
- Spark学习笔记——键值对操作
- Java参数验证Bean Validation 框架
- java常用设计模式五:建造者模式
- JFinal 3.3 学习 -- JFinalConfig (配置web项目)
热门文章
- Leetcode173. Binary Search Tree Iterator二叉搜索树迭代器
- Leetcode105. Construct Binary Tree from Preorder and Inorder Traversal前序与中序构造二叉树
- 读取复杂结构的yml配置项
- 威胁快报|ProtonMiner挖矿蠕虫扩大攻击面,加速传播
- git bash 常用操作文件命令行
- Delphi 设计模式:《HeadFirst设计模式》Delphi7代码---状态模式[转]
- 学习Python笔记---if 语句
- 深入理解PHP类的自动载入机制方法
- 【python之路16】lambda表达式
- 编译libusb库