ural 1150. Page Numbers
1150. Page Numbers
Memory limit: 64 MB
Input
Output
Sample
input | output |
---|---|
12 |
1 |
Problem Source: Ural Collegiate Programming Contest, April 2001, Perm, English Round
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <ctime>
using namespace std;
typedef long long LL;
typedef double DB;
#define For(i, s, t) for(int i = (s); i <= (t); i++)
#define Ford(i, s, t) for(int i = (s); i >= (t); i--)
#define Rep(i, t) for(int i = (0); i < (t); i++)
#define Repn(i, t) for(int i = ((t)-1); i >= (0); i--)
#define rep(i, x, t) for(int i = (x); i < (t); i++)
#define MIT (2147483647)
#define INF (1000000001)
#define MLL (1000000000000000001LL)
#define sz(x) ((int) (x).size())
#define clr(x, y) memset(x, y, sizeof(x))
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back
#define ft first
#define sd second
#define mk make_pair
inline void SetIO(string Name) {
string Input = Name+".in",
Output = Name+".out";
freopen(Input.c_str(), "r", stdin),
freopen(Output.c_str(), "w", stdout);
} inline int Getint() {
int Ret = ;
char Ch = ' ';
while(!(Ch >= '' && Ch <= '')) Ch = getchar();
while(Ch >= '' && Ch <= '') {
Ret = Ret*+Ch-'';
Ch = getchar();
}
return Ret;
} const int N = ;
int n;
LL Ans[N]; inline void Input() {
scanf("%d", &n);
} inline void Solve() {
LL x, y;
int Now = ;
while(n/Now) {
x = n/(Now*), y = n%Now;
int p = (n/Now)%;
if(!p) Ans[] += (x-)*Now+y+;
else Ans[] += x*Now;
For(i, , p-) Ans[i] += (x+)*Now;
if(p) Ans[p] += x*Now+y+;
For(i, p+, ) Ans[i] += x*Now;
Now *= ;
//cout<<Ans[0]<<endl;
} Rep(i, N) cout<<Ans[i]<<endl;
} int main() {
#ifndef ONLINE_JUDGE
SetIO("A");
#endif
Input();
Solve();
return ;
}
ural 1150. Page Numbers的更多相关文章
- 递推DP URAL 1586 Threeprime Numbers
题目传送门 /* 题意:n位数字,任意连续的三位数字组成的数字是素数,这样的n位数有多少个 最优子结构:考虑3位数的数字,可以枚举出来,第4位是和第3位,第2位组成的数字判断是否是素数 所以,dp[i ...
- 递推DP URAL 1009 K-based Numbers
题目传送门 题意:n位数,k进制,求个数分析:dp[i][j] 表示i位数,当前数字为j的个数:若j==0,不加dp[i-1][0]; 代码1: #include <cstdio> #in ...
- [codeforces]Page Numbers <模拟>
描述: «Bersoft» company is working on a new version of its most popular text editor — Bord 2010. Bord, ...
- ural 2070. Interesting Numbers
2070. Interesting Numbers Time limit: 2.0 secondMemory limit: 64 MB Nikolay and Asya investigate int ...
- URAL 2031. Overturned Numbers (枚举)
2031. Overturned Numbers Time limit: 1.0 second Memory limit: 64 MB Little Pierre was surfing the In ...
- URAL 1002 Phone Numbers(KMP+最短路orDP)
In the present world you frequently meet a lot of call numbers and they are going to be longer and l ...
- URAL 1233 Amusing Numbers 好题
参照了nocow上的解法,照搬过来…… 易知一个数X在数列中在另一个数Y前,当且仅当X前缀小于Y或前缀相等X短,那么我们分布考虑,比如对于数48561: 5位上:10000~48560; 4位上:10 ...
- URAL 1012 K-based Numbers. Version 2(DP+高精度)
题目链接 题意 :与1009一样,不过这个题的数据范围变大. 思路:因为数据范围变大,所以要用大数模拟,用java也行,大数模拟也没什么不过变成二维再做就行了呗.当然也可以先把所有的都进行打表,不过要 ...
- ural 1118. Nontrivial Numbers
1118. Nontrivial Numbers Time limit: 2.0 secondMemory limit: 64 MB Specialists of SKB Kontur have de ...
随机推荐
- xcode6以后, 使用.pch
http://blog.csdn.net/lihuiqwertyuiop/article/details/39268101 总结: . 创建.pch文件 . Apple LLVM 6.1 - Lang ...
- facedetect
继续学习大神的博文http://www.cnblogs.com/tornadomeet/archive/2012/03/22/2411318.html
- Linux MySQL 存储引擎详解
MySQL常用的存储引擎为MyISAM.InnoDB.MEMORY.MERGE,其中InnoDB提供事务安全表,其他存储引擎都是非事务安全表. MyISAM是MySQL的默认存储引擎.MyISAM不支 ...
- ubuntu安装到选择位置时闪退
转自:http://tieba.baidu.com/p/3020839207
- 【Python】Django 如何直接返回404 被 curl,wget 捕获到
代码示例: from django.http import Http404, HttpResponseNotFound #raise Http404(filename) return HttpResp ...
- 用数据表创建树_delphi教程
数据库结构:字段 类型ID 整型 索引(无重复)name 文本father 整型 //tree初始化procedure TForm1.FormActivate(Sender: TObject);var ...
- Greedy:Saruman's Army(POJ 3069)
2015-09-06 萨鲁曼军队 问题大意:萨鲁曼白想要让他的军队从sengard到Helm’s Deep,为了跟踪他的军队,他在军队中放置了魔法石(军队是一条线),魔法石可以看到前后距离为R的距离, ...
- 【USACO】calfflac
关键:以回文中心位置为变量进行遍历 //必须把纯字母先提出来 否则肯能会出现错误 比如: lvlv= 在检查长度4时 lvlv认为不是回文 vlv=认为是回文 但实际上 lvl 出现的要更早一些 // ...
- mac os 显示文件列表命令 ls -a
显示正常文件列表用ls就行了,但是要是想显示隐藏的文件,需要加-a
- Androidi性能优化之多线程和同步
线程: 创建线程的方法: a:定义Thread类的实例,并start(); b:实现Runnable接口,并作为参数传给Thread类的实例,然后start(); 不管线程是通过什么方式创建的,它都有 ...