hdoj 3184 All Can Do
来源:互联网 发布:合肥工业大学网络公选 编辑:程序博客网 时间:2024/06/01 19:01
All Can Do
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 550 Accepted Submission(s): 206
Problem Description
Construct a number N follows three below restrictions:
1. T-1 <= Log10N < T, ( 0 < T <= 100 )
2. 90 mod b = 0
3. N mod b = 0
Please help me find the biggest N.
1. T-1 <= Log10N < T, ( 0 < T <= 100 )
2. 90 mod b = 0
3. N mod b = 0
Please help me find the biggest N.
Input
The first line contains an integer t means the number of test cases.
Then each line will contain two integers T and b.
Then each line will contain two integers T and b.
Output
For each case, output N in one line, if there is no such answer, output "Impossible!".
Sample Input
32 451 102 5
Sample Output
90Impossible!95
巧法:
#include<stdio.h>#include<string.h>#include<math.h>int T,b;void solve(){ int i; if(b==1||b==3||b==9)//T个9 { for(i=0;i<T;i++) { printf("9"); } printf("\n"); } else if(b==2)//T-1个9 一个8 { for(i=0;i<T-1;i++) { printf("9"); } printf("8\n"); } else if(b==5)//T-1个9 一个5 { for(i=0;i<T-1;i++) { printf("9"); } printf("5\n"); } else if(b==6)//T-1个9 一个6 { for(i=0;i<T-1;i++) { printf("9"); } printf("6\n"); } else//T-1个9 一个0 { for(i=0;i<T-1;i++) printf("9"); printf("0\n"); }}int main(){ int t; scanf("%d",&t); while(t--) { scanf("%d%d",&T,&b); if(90%b||T==1&&b>=10) { printf("Impossible!\n"); continue; } solve(); } return 0;}
0 0
- hdoj 3184 All Can Do
- HDU-3184-All Can Do【思维】
- HDU3184:All Can Do
- hdu3184 All Can Do
- HDOJ 3552 I can do it!
- HDOJ 3552 I can do it!(贪心)
- hdoj 3552 I can do it! 【思维】
- hdoj I can do it! 3552 (贪心&模拟)
- hdoj--3552--I can do it!(贪心模拟)
- HDOJ--3552--I can do it!(思维)
- Attitude, Can do, Can't do
- What can we do?
- WPF Can Do
- WPF Can Do
- what can i do?
- what can i do
- can you do it
- what python can do
- Bootstrap JS插件使用实例(1)-轮播
- 第四章作业
- Java多态性理解
- 使用bootstrap搭建后台界面(一)列表展示
- bootstrap后台模板布局
- hdoj 3184 All Can Do
- struts2绑定对象数组
- 图像处理函数详解——padarray
- jQuery返回顶部效果
- matlab 把m文件编译成可执行文件
- hdu 1569 方格取数(2) 网络流 最大点权独立集
- enum,EnumMap,EnumSet
- 安卓学习第十七天:相对布局的初步使用与换源学习
- Myeclipse中无法删除部署在tomcat上的工程