URAL 1385 Interesting Number (暴力打表 + 找规律)
来源:互联网 发布:火影忍者刷金币软件 编辑:程序博客网 时间:2024/06/05 15:52
题目大意:
给出一个N,要求求出有多少个2*N位的整数,其前N位组成的数和后N位组成的数都能被2N位的这个整数整除
比如说 n = 1时 11 %1 == 0 && 11 % 1 == 0
15 %1 == 0 && 15 % 5 == 0
那么11和15都是满足条件的数,n = 1时满足条件的数有11,12,15,22,24,33,36,44,48,55,66,77,88,99
一共14个,所以输入 n为1时输出16
大致思路:
假设这个2*N位的整数的前n位形成的数是 k1, 后n位形成的数是 k2
那么,原来的数就是 k1*(10^n) + k2
由于 10^(n - 1) <= k1 <= (10^n) - 1 且 0 <= k2 <= (10^n) - 1
要使得k1*(10^k2) + k2 能被k1, 和 k2 整除,k1*(10^n)/k2 和 k2/k1都必须是整数
当n == 1时, k2/k1 只能是1,2,5,这样(k1/k2) *10 才能是整数
当 n == 2时, k2/k1只能是1,2,4,5这样(k1/k2)*100能是整数
当n >= 3 时, k2/k1可以使1,2,4,5,8这样(k1/k2)*(10^n)能是整数
如此,便可以暴力枚举n <= 5的情况:
n == 1 answer is 14
n == 2 answer is 155
n == 3 answer is 1575
n == 4 answer is 15750
n == 5 answer is 157500 //这个我暴力用的时间久开始比较长了,n == 6就没有继续打了
猜想: n >= 3时答案为 1575 + (n - 3)个零
交上去AC.....打表万岁...
证明不太清楚...
/* * Author: Gatevin * Created Time: 2014/7/21 13:32:14 * File Name: hehe.cpp */#include<iostream>#include<sstream>#include<fstream>#include<vector>#include<list>#include<deque>#include<queue>#include<stack>#include<map>#include<set>#include<bitset>#include<algorithm>#include<cstdio>#include<cstdlib>#include<cstring>#include<cctype>#include<cmath>#include<ctime>#include<iomanip>using namespace std;const double eps(1e-8);typedef long long lint;int main(){ int N; cin>>N; if(N == 1) { cout<<"14\n"<<endl; return 0; } if(N == 2) { cout<<"155"<<endl; return 0; } if(N == 3) { cout<<"1575"<<endl; return 0; } if(N >= 4) { cout<<"1575"; for(int i = 1; i <= N - 3; i++) { cout<<"0"; } cout<<endl; } return 0;}
- URAL 1385 Interesting Number (暴力打表 + 找规律)
- URAL 1385 Interesting Number
- URAL 1385 Interesting Number
- Number Sequence 【打表】+【找规律】
- hdu 5512 Pagodas【暴力打表+找规律】
- 数学 | 推理 | 思维 | 打表 | 找规律 | 贪心 | 暴力
- zoj 3622 Magic Number (找规律+打表)
- UVA 10706 Number Sequence (找规律 + 打表 + 查找)
- hdoj 1005 Number Sequence (找规律,打表)
- URAL 1385 Interesting Number 解题报告
- Hdu 5793 A Boring Question【暴力打表+找规律+求逆元+快速幂+快速积】
- URAL 2070. Interesting Numbers(素数打表 数学题)
- hdu5917Instability(找规律+暴力)
- Alarm(找规律+素数打表)
- hdu_6124_打表_找规律
- URAL - 1117 Hierarchy(找规律)
- HDU 4952 Number Transformation 打表规律
- Number Sequence 找规律
- 获取网页内容高度和宽度(不包括滚动条)兼容性JS解决办法
- 浅谈并发服务器---多线程并发---4(线程安全)
- 微信公众平台开发第一步(Java)——接口验证问题
- LeetCode Text Justification
- 百度员工离职总结:如何做个好员工
- URAL 1385 Interesting Number (暴力打表 + 找规律)
- Linux下patch的制作和应用
- http请求的过程
- 软件可行性分析与需求分析经典论述
- android屏蔽listview 的item事件
- 利用jquery的ajax实现异步请求发送数据到后台
- Spring的AOP配置(基于xml)
- JIRA 数据库 设计 点滴
- 归并排序