1289. One Way Ticket

Time limit: 1.0 second
Memory limit: 64 MB
A crowed of volunteers dressed in the star striped overalls have filled the starport. There starcraft leaves to the thorium mines of Haron. Their job will be hard and dangerous. Will many of them return home?
This question has an exact answer. Each of the volunteers has a ticket to the starcraft. There signed a compartment number where he is to fly. The starcraft is not passenger, it departs to Haron once a month full of the volunteers and returns back loaded with thorium. This precious metal can be loaded not in all of the compartments. In such a compartments volunteers can return home. All the others are to stay at Haron... Forever.
The compartments are numbered. The numbers of the unfit compartments (and only their numbers) are so that the digit root of the first half of the number equals to the digit root of the second half. To calculate the digit root of a number one is to summarize the digits of the number; if the result is greater or equal than 10, then the digits of the result are to be summarized again; and so on until one gets a number from 0 to 9.
How many volunteers will return home?

Input

Even integer number N ≤ 200000 – an amount of digits used to number the compartments. There are exactly 10N compartments numbered from 0 to 10N-1 with the leading zeros.

Output

The number of compartments free of thorium on the way home.

Sample

input output
2
10
Problem Author: Leonid Volkov
Problem Source: USU Personal Contest 2004
Difficulty: 391
 
题意:问前一半的数字根和后一半数字的数字根相同的n位数有多少(可以有前缀零)
分析:首先,数字根为零的话显然只能是00....000这样全部是零
然后其他数字根肯定是1-9
令m=n/2(n必为偶数)
前m位共有设为k=10^m-1=99...999(m个9)个数,显然,每个数字根1111...111(m个1)=k/9个数
同样的,后m位共有k个数,显然,每个数字根k/9个数
然后就很显然了。。。
答案就是Ans = k * (k / 9) + 1
 
写下高精度就好
但是,999...999 * 111..111是有规律的。。。而且很容易找。。
所以高精度都不用写了。。。
 #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 = ' ';
bool Flag = ;
while(!(Ch >= '' && Ch <= '')) {
if(Ch == '-') Flag ^= ;
Ch = getchar();
}
while(Ch >= '' && Ch <= '') {
Ret = Ret*+Ch-'';
Ch = getchar();
}
return Flag ? -Ret : Ret;
} int n; inline void Input() {
cin>>n;
} inline void Solve() {
n /= ;
if(n == ) puts("");
else {
For(i, , n-) printf("");
printf("");
For(i, , n-) printf("");
printf("");
}
} int main() {
#ifndef ONLINE_JUDGE
SetIO("G");
#endif
Input();
Solve();
return ;
}

ural 1289. One Way Ticket的更多相关文章

  1. ural 1217. Unlucky Tickets

    1217. Unlucky Tickets Time limit: 1.0 secondMemory limit: 64 MB Strange people live in Moscow! Each ...

  2. URAL 1796. Amusement Park (math)

    1796. Amusement Park Time limit: 1.0 second Memory limit: 64 MB On a sunny Sunday, a group of childr ...

  3. URAL 1036(dp+高精度)

    Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Status Pract ...

  4. Ural 1036 Lucky Tickets

    Lucky Tickets Time Limit: 2000ms Memory Limit: 16384KB This problem will be judged on Ural. Original ...

  5. URAL 2092 Bolero 贪心

    C - Bolero Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit S ...

  6. [Kerberos] User Ticket Management

    Kerberos客户端常用命令包括 kinit, klist, kdestroy, and kpasswd,用户使用这些命令管理自己的 ticket. 此外,每台运行Kerberos的机器应该都配置/ ...

  7. 實際案例: 獲取臨時票証 (JsApi Ticket)

    專案中選用大名鼎鼎的 Senparc 微信開發套件 獲取臨時票證處理常式的程式碼 (GetgVXinInfo.ashx) using Senparc.Weixin; using Senparc.Wei ...

  8. Gitblit中采用Ticket模式进行协作开发

    Git目前的代码分支管理模型中,比较主要的有Git-Flow.Github Pull Request.大家日常或多或少都在用着. 在不想安装Gitlab这种重量级的环境的情况下,如果是利用git一步步 ...

  9. 后缀数组 POJ 3974 Palindrome && URAL 1297 Palindrome

    题目链接 题意:求给定的字符串的最长回文子串 分析:做法是构造一个新的字符串是原字符串+反转后的原字符串(这样方便求两边回文的后缀的最长前缀),即newS = S + '$' + revS,枚举回文串 ...

随机推荐

  1. Leetcode 之Convert Sorted List to Binary Search Tree(55)

    和上题思路基本一致,不同的地方在于,链表不能随机访问中间元素. int listLength(ListNode* node) { ; while (node) { n++; node = node-& ...

  2. 【Python】Django 时间字段 最佳实践

    . python datetime from datetime import datetime datetime.now() datetime.utcnow() from datetime impor ...

  3. 【转】Linux中如何安装.rpm、.tar、.tar.gz和tar.bz2

    我以下面三个包为例:(三个包都在/etc/opt下)A.example-1.2.3-1.rpmB.example-1.2.3-1.tarC.example-1.2.3-1.tar.gz 1.对于rpm ...

  4. Python yield 使用浅析(转)

    Python yield 使用浅析 初学 Python 的开发者经常会发现很多 Python 函数中用到了 yield 关键字,然而,带有 yield 的函数执行流程却和普通函数不一样,yield 到 ...

  5. 23.跳台阶问题[Fib]

    [题目] 一个台阶总共有n级,如果一次可以跳1级,也可以跳2级.求总共有多少总跳法,并分析算法的时间复杂度. [分析] 首先我们考虑最简单的情况.如果只有1级台阶,那显然只有一种跳法.如果有2级台阶, ...

  6. DroidDraw - Android的界面设计工具

    ADT中的界面开发工具实在是很烂,通常情况下都需要硬编码,对于程序员来说不但效率比较低下,而且调试起来极其不方便,还好在Google未推出GUI的"所见即所得"的工具之前,我们找到 ...

  7. CodeForces - 427B (模拟题)

    Prison Transfer Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Sub ...

  8. fuser命令小结

    前提 linux环境下,当使用umount命令卸载挂载点时,会遇到“device is busy”提示,这时fuser就能查出谁在使用这个资源;当然umount –lf  [挂载点] 也可以强制卸载 ...

  9. SPI通信实验---verilog(FPGA作为从机,使用可读可写)

    本实验讲究实用性,故设计思想为:主机先向从机发送地址,若是向从机写入数据,则向从机发送数据,若是读取从机数据,则向从机发送时钟,然后在时钟下降沿读取数据即可.cs信号上升沿作为SPI通信的结束信号.r ...

  10. time_wait 过多 造成网络慢 实战

    sh-3.2# scripts]# netstat -an|awk '/tcp/ {++S[$NF]}END {for (a in S) print a,S[a]}' TIME_WAIT ESTABL ...