Light OJ 1116 - Ekka Dokka
2015-12-01 20:44
218 查看
Ekka Dokka
![]() | PDF (English) | Statistics | Forum |
Time Limit: 2 second(s) | Memory Limit: 32 MB |
cake such that Ekka gets a share of N square centimeters and Dokka gets a share of M square centimeters where N is odd and M is even. Both N and M are positive
integers.
They want to divide the cake such that N * M = W, where W is the dashing factor set by them. Now you know their dashing factor, you have to find whether they can buy the desired cake or not.
Input
Input starts with an integer T (≤ 10000), denoting the number of test cases.Each case contains an integer W (2 ≤ W < 263). And W will not be a power of 2.
Output
For each case, print the case number first. After that print "Impossible" if they can't buy their desired cake. If they can buy such a cake, you have to print N and M. If there are multiple solutions, thenprint the result where M is as small as possible.
Sample Input | Output for Sample Input |
3 10 5 12 | Case 1: 5 2 Case 2: Impossible Case 3: 3 4 |
<span style="font-family:Comic Sans MS;">#include <iostream> #include<cstdio> #include<cstring> #include<cmath> using namespace std; typedef long long LL; int main() { int t,cnt=0; LL w,n,m; scanf("%d",&t); while(t--) { scanf("%lld",&w); printf("Case %d: ",++cnt); m=2; int flag=0; if(w&1) { printf("Impossible\n"); continue; } while(m<=w) { n=w/m; if(n*m==w&&n&1) { flag=1; break; } m+=2; } if(flag) printf("%lld %lld\n",n,m); else printf("Impossible\n"); } return 0; }</span>
相关文章推荐
- ios学习之个人笔记(超级猜图)
- Linux下搭建SVN服务器
- MyEclipse使用经验归纳
- 5.x控件:FloatingActionButton、SnackBar、DrawerLayout、NavigationView
- Spring4 AOP详解
- UI(二)
- x&(x-1)
- java web简单权限管理设计
- runtime实践之Method Swizzling
- 探索需求--设计前的质量之三
- CYC-多线程之详解
- apache 配置
- lodash用法系列(1),数组集合操作
- 12月1号 MacOS系统命令行操作方式
- ZigZag Conversion
- 探索需求——设计前的质量之一
- LightOJ 1275 - Internet Service Providers (简单数学)
- Android异步加载(二)
- 矩阵快速幂模板
- hadoop和spark搭建记录