【HDOJ】4541 Ten Googol
打表的大水题。
/* 4541 */
#include <cstdio>
#include <cstdlib>
#include <cstring> int a3[] = {, , , };
int a4[] = {, , , };
int a5[] = {, , , , , };
int a6[] = {, , , , , };
int a7[] = {, , };
int a8[] = {, , , , , , , , , , , , };
int a9[] = {, , , , , , , , , , , , , , , , , , , , , }; int main() {
int t, m, n;
int n3, n4, n5, n6, n7, n8, n9;
int i; #ifndef ONLINE_JUDGE
freopen("data.in", "r", stdin);
freopen("data.out", "w", stdout);
#endif n3 = sizeof(a3)/sizeof(int);
n4 = sizeof(a4)/sizeof(int);
n5 = sizeof(a5)/sizeof(int);
n6 = sizeof(a6)/sizeof(int);
n7 = sizeof(a7)/sizeof(int);
n8 = sizeof(a8)/sizeof(int);
n9 = sizeof(a9)/sizeof(int); scanf("%d", &t);
for (i=; i<=t; ++i) {
scanf("%d %d", &n, &m);
printf("Case #%d: ", i);
--m;
if (n == ) {
if (m >= n3)
printf("-1\n");
else
printf("%d\n", a3[m]);
}
if (n == ) {
if (m >= n4)
printf("-1\n");
else
printf("%d\n", a4[m]);
}
if (n == ) {
if (m >= n5)
printf("-1\n");
else
printf("%d\n", a5[m]);
}
if (n == ) {
if (m >= n6)
printf("-1\n");
else
printf("%d\n", a6[m]);
}
if (n == ) {
if (m >= n7)
printf("-1\n");
else
printf("%d\n", a7[m]);
}
if (n == ) {
if (m >= n8)
printf("-1\n");
else
printf("%d\n", a8[m]);
}
if (n == ) {
if (m < n9)
printf("%d\n", a9[m]);
else if (m == n9)
printf("10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n");
else if (m == n9+)
printf("20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n");
else if (m == n9+)
printf("60000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n");
else if (m == n9+)
printf("100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000\n");
else
printf("-1\n");
}
} return ;
}
【HDOJ】4541 Ten Googol的更多相关文章
- 【HDOJ】4729 An Easy Problem for Elfness
其实是求树上的路径间的数据第K大的题目.果断主席树 + LCA.初始流量是这条路径上的最小值.若a<=b,显然直接为s->t建立pipe可以使流量最优:否则,对[0, 10**4]二分得到 ...
- 【HDOJ】【3506】Monkey Party
DP/四边形不等式 裸题环形石子合并…… 拆环为链即可 //HDOJ 3506 #include<cmath> #include<vector> #include<cst ...
- 【HDOJ】【3516】Tree Construction
DP/四边形不等式 这题跟石子合并有点像…… dp[i][j]为将第 i 个点开始的 j 个点合并的最小代价. 易知有 dp[i][j]=min{dp[i][j] , dp[i][k-i+1]+dp[ ...
- 【HDOJ】【3480】Division
DP/四边形不等式 要求将一个可重集S分成M个子集,求子集的极差的平方和最小是多少…… 首先我们先将这N个数排序,容易想到每个自己都对应着这个有序数组中的一段……而不会是互相穿插着= =因为交换一下明 ...
- 【HDOJ】【2829】Lawrence
DP/四边形不等式 做过POJ 1739 邮局那道题后就很容易写出动规方程: dp[i][j]=min{dp[i-1][k]+w[k+1][j]}(表示前 j 个点分成 i 块的最小代价) $w(l, ...
- 【HDOJ】【3415】Max Sum of Max-K-sub-sequence
DP/单调队列优化 呃……环形链求最大k子段和. 首先拆环为链求前缀和…… 然后单调队列吧<_<,裸题没啥好说的…… WA:为毛手写队列就会挂,必须用STL的deque?(写挂自己弱……s ...
- 【HDOJ】【3530】Subsequence
DP/单调队列优化 题解:http://www.cnblogs.com/yymore/archive/2011/06/22/2087553.html 引用: 首先我们要明确几件事情 1.假设我们现在知 ...
- 【HDOJ】【3068】最长回文
Manacher算法 Manacher模板题…… //HDOJ 3068 #include<cstdio> #include<cstring> #include<cstd ...
- 【HDOJ】【1512】Monkey King
数据结构/可并堆 啊……换换脑子就看了看数据结构……看了一下左偏树和斜堆,鉴于左偏树不像斜堆可能退化就写了个左偏树. 左偏树介绍:http://www.cnblogs.com/crazyac/arti ...
随机推荐
- Demo_敌军坦克生成,坦克移动(可以拓展发射子弹,敌军消失获取分数或者添加动画,声音功能)
using UnityEngine; using System.Collections; public class Tank : MonoBehaviour { //坦克面积结构体对象 public ...
- CSS3实现文字描边
-webkit-text-shadow:#000 1px 0 0,#000 0 1px 0,#000 -1px 0 0,#000 0 -1px 0; -moz-text-shadow:#000 1px ...
- 在JAVA中 System.getProperty 和 System.setProperty 方法.
今天着手研究TOMCAT源码. 在刚開始的时候Startup类中init方法中调用非常多次System.getProperty和System.setProperty的方法. 后来经过网上搜索才得知,这 ...
- 递归---NYOJ-90整数划分(一)
这个题理解了好大会才理解,看了网上的代码,不太理解,但是后来看了好几个人的, 大同小异吧,慢慢的就理解了. 思路: 递归函数的意思是, 将 n 划分为最大数为 m 的划分数, 可以分几种情况 1. 当 ...
- MySQL安装与测试
工作室老师要求我们把MySQL装出来 今天折腾了下,本来不难的,不知道为什么用最新5.6.24的msi安装包,安装的时候选完路径后就没有后续了..蛋疼的我试了好几次,用cmd命令测试一直是 2003- ...
- javascript基础之自执行函数
1.匿名函数的定义方式 如下 var temp = function(){} 2.自执行函数 (function(){ 内容 }) () 不带参数 (fun ...
- android-Activity的执行流程
概述 The following diagram shows the important state paths of an Activity. The square rectangles repre ...
- shell中if做比较
比较两个字符串是否相等的办法是: if [ "$test"x = "test"x ]; then 这里的关键有几点: 1 使用单个等号 2 注意到等号两边各有一 ...
- 关于——NSThread
创建.启动线程 NSThread *thread = [[NSThread alloc] initWithTarget:self selector:@selector(run) object:nil] ...
- PHP Cookies
PHP Cookies cookie 常用于识别用户. Cookie 是什么? cookie 常用于识别用户.cookie 是一种服务器留在用户计算机上的小文件.每当同一台计算机通过浏览器请求页面时, ...