hdu 4956 Yet another end of the world ( 取模转化)
来源:互联网 发布:顶级源码 编辑:程序博客网 时间:2024/06/05 08:24
Problem Description
In the year 3013, it has been 1000 years since the previous predicted rapture. However, the Maya will not play a joke any more and the Rapture finally comes in. Fortunately people have already found out habitable planets, and made enough airships to convey all the human beings in the world. A large amount of airships are flying away the earth. People all bear to watch as this planet on which they have lived for millions of years. Nonetheless, scientists are worrying about anther problem…
As we know that long distance space travels are realized through the wormholes, which are given birth by the distortion of the energy fields in space. Airships will be driven into the wormholes to reach the other side of the universe by the suction devices placed in advance. Each wormhole has its configured attract parameters, X, Y or Z. When the value of ID%X is in [Y,Z], this spaceship will be sucked into the wormhole by the huge attraction. However, the spaceship would be tear into piece if its ID meets the attract parameters of two wormholes or more at the same time.
All the parameters are carefully adjusted initially, but some conservative, who treat the Rapture as a grain of truth and who are reluctant to abandon the treasure, combine with some evil scientists and disrupt the parameters. As a consequence, before the spaceships fly into gravity range, we should know whether the great tragedy would happen or not. Now the mission is on you.
As we know that long distance space travels are realized through the wormholes, which are given birth by the distortion of the energy fields in space. Airships will be driven into the wormholes to reach the other side of the universe by the suction devices placed in advance. Each wormhole has its configured attract parameters, X, Y or Z. When the value of ID%X is in [Y,Z], this spaceship will be sucked into the wormhole by the huge attraction. However, the spaceship would be tear into piece if its ID meets the attract parameters of two wormholes or more at the same time.
All the parameters are carefully adjusted initially, but some conservative, who treat the Rapture as a grain of truth and who are reluctant to abandon the treasure, combine with some evil scientists and disrupt the parameters. As a consequence, before the spaceships fly into gravity range, we should know whether the great tragedy would happen or not. Now the mission is on you.
Input
Multiple test cases, ends with EOF.
In each case, the first line contains an integer N(N<=1000), which means the number of the wormholes.
Then comes N lines, each line contains three integers X,Y,Z(0<=Y<=Z<X<2*109).
In each case, the first line contains an integer N(N<=1000), which means the number of the wormholes.
Then comes N lines, each line contains three integers X,Y,Z(0<=Y<=Z<X<2*109).
Output
If there exists danger, output “Cannot Take off”, else output “Can Take off”.
Sample Input
27 2 37 5 627 2 29 2 2
Sample Output
Can Take offCannot Take off
题意;(有点难懂)
代码:
#include <iostream>#include <cstdio>#include <algorithm>#include <vector>#include <cstring>#include <cstdlib>#include <string>#include <cmath>#include <set>#include <map>#include <bitset>using namespace std;typedef long long ll;const int mod = 1000000003;const double eps = 1e-6;const int inf = 0x3f3f3f3f;const ll INF = 100000000000000000ll;int gcd(int a,int b){ int t; while(b) { t= b; b = a%b; a=t; } return a;}bool ok(int t,int r,int l){ if(r*l<=0) return 1; if(r<0) {r=-r;l=-l;} if(r<l) swap(r,l); if(r-l+1>=t) return 1; if(l%t==0) return 1; int cc = l/t; if((cc+1)*t <= r) return 1; return 0;}int n;int a[1200];int b[1200];int c[1200];int main(){ while(scanf("%d",&n)!=EOF) { for(int i=0; i<n; i++) scanf("%d%d%d",&a[i],&b[i],&c[i]); int gc; bool flag=false; for(int i=0; i<n&&!flag; i++) for(int j=i+1; j<n; j++) { gc= gcd(a[i],a[j]); if(ok(gc,b[i]-c[j],c[i]-b[j])) { flag=true; break; } } if(flag) printf("Cannot Take off\n"); else printf("Can Take off\n"); } return 0;}
Problem Description
In the year 3013, it has been 1000 years since the previous predicted rapture. However, the Maya will not play a joke any more and the Rapture finally comes in. Fortunately people have already found out habitable planets, and made enough airships to convey all the human beings in the world. A large amount of airships are flying away the earth. People all bear to watch as this planet on which they have lived for millions of years. Nonetheless, scientists are worrying about anther problem…
As we know that long distance space travels are realized through the wormholes, which are given birth by the distortion of the energy fields in space. Airships will be driven into the wormholes to reach the other side of the universe by the suction devices placed in advance. Each wormhole has its configured attract parameters, X, Y or Z. When the value of ID%X is in [Y,Z], this spaceship will be sucked into the wormhole by the huge attraction. However, the spaceship would be tear into piece if its ID meets the attract parameters of two wormholes or more at the same time.
All the parameters are carefully adjusted initially, but some conservative, who treat the Rapture as a grain of truth and who are reluctant to abandon the treasure, combine with some evil scientists and disrupt the parameters. As a consequence, before the spaceships fly into gravity range, we should know whether the great tragedy would happen or not. Now the mission is on you.
As we know that long distance space travels are realized through the wormholes, which are given birth by the distortion of the energy fields in space. Airships will be driven into the wormholes to reach the other side of the universe by the suction devices placed in advance. Each wormhole has its configured attract parameters, X, Y or Z. When the value of ID%X is in [Y,Z], this spaceship will be sucked into the wormhole by the huge attraction. However, the spaceship would be tear into piece if its ID meets the attract parameters of two wormholes or more at the same time.
All the parameters are carefully adjusted initially, but some conservative, who treat the Rapture as a grain of truth and who are reluctant to abandon the treasure, combine with some evil scientists and disrupt the parameters. As a consequence, before the spaceships fly into gravity range, we should know whether the great tragedy would happen or not. Now the mission is on you.
Input
Multiple test cases, ends with EOF.
In each case, the first line contains an integer N(N<=1000), which means the number of the wormholes.
Then comes N lines, each line contains three integers X,Y,Z(0<=Y<=Z<X<2*109).
In each case, the first line contains an integer N(N<=1000), which means the number of the wormholes.
Then comes N lines, each line contains three integers X,Y,Z(0<=Y<=Z<X<2*109).
Output
If there exists danger, output “Cannot Take off”, else output “Can Take off”.
Sample Input
27 2 37 5 627 2 29 2 2
Sample Output
Can Take offCannot Take off
0 0
- hdu 4956 Yet another end of the world ( 取模转化)
- Hdu 4596 Yet another end of the world(数论)
- HDU 4596Yet another end of the world(GCD)
- HDU-4596 Yet another end of the world (数论)
- hdu 4596 Yet another end of the world(数论)
- HDU 4596 Yet another end of the world
- [欧几里得] hdu 4596 Yet another end of the world
- HDU OJ 4596 Yet another end of the world
- HDU 4569——Yet another end of the world
- HDU 4596 Yet another end of the world (拓展欧几里得)
- Yet another end of the world
- HDU 4596 (Yet another end of the world)(二进制进位次数和)
- (数论)HDU 4596 Yet another end of the world题解
- hdu 4596 Yet another end of the world (一阶不定方程可解性 )
- hdu 4596 Yet another end of the world (一阶不定方程可解性 )
- HDU 4596 Yet another end of the world (扩展欧几里德)
- HDU 4596 Yet another end of the world(一阶不定方程是否可解,gcd)
- HDU 4596 - Yet another end of the world(扩展欧几里得)
- c#图片在PictureBox内任意角度旋转问题(360度)
- android init.rc中启动的service 默认是disable的,后续如何启动此服务
- 加载单页面应用IOS端出现黑屏的问题,解决方案
- mongoVUE中collections为空,即文件树无法展开问题的解决策略
- poj3176Cow Bowling,数字三角形,动态规划
- hdu 4956 Yet another end of the world ( 取模转化)
- 开启nginx状态监控
- WebView进行post请求
- HDU 1789 Doing Homework again 贪心
- 组合逻辑和时序逻辑
- 关于js原型继承
- 静态方法与非静态方法的区别
- maven 私服搭建(nexus)
- 怎么实现图片的圆角展示还有阴影展示