SG6. 死锁
描述
试判断一个消息队列是否可能死锁。输入描述
第1行输入N(N<=10)表示数据组数。输出描述
输出N行,每行输出'YES'或'NO'示例1
输入:
2 5 2 3 5 3 4
输出:
NO YES
C++14 解法, 执行用时: 2ms, 内存消耗: 376KB, 提交时间: 2020-05-20
#include<stdio.h> #include<string.h> typedef long long LL; LL GCD(LL a,LL b){ if(b==0) return a; else return GCD(b,a%b); } int main() { // freopen("input.txt", "r", stdin); int n; LL l, r, w; int remain; scanf("%d", &n); while(n--) { scanf("%lld%lld%lld", &l, &r, &w); LL g=GCD(r,w); if(r+w-g>l) printf("YES\n"); else printf("NO\n"); } return 0; }
C++14 解法, 执行用时: 2ms, 内存消耗: 376KB, 提交时间: 2020-05-17
#include<stdio.h> #include<string.h> typedef long long LL; LL GCD(LL a,LL b){ if(b==0) return a; else return GCD(b,a%b); } int main() { // freopen("input.txt", "r", stdin); int n; LL l, r, w; int remain; scanf("%d", &n); while(n--) { scanf("%lld%lld%lld", &l, &r, &w); LL g=GCD(r,w); if(r+w-g>l) printf("YES\n"); else printf("NO\n"); } return 0; }
C++14 解法, 执行用时: 2ms, 内存消耗: 376KB, 提交时间: 2020-04-27
#include<stdio.h> #include<string.h> typedef long long LL; LL GCD(LL a,LL b){ if(b==0) return a; else return GCD(b,a%b); } int main() { // freopen("input.txt", "r", stdin); int n; LL l, r, w; int remain; scanf("%d", &n); while(n--) { scanf("%lld%lld%lld", &l, &r, &w); LL g=GCD(r,w); if(r+w-g>l) printf("YES\n"); else printf("NO\n"); } return 0; }
C++ 解法, 执行用时: 2ms, 内存消耗: 380KB, 提交时间: 2020-10-31
#include<stdio.h> #include<string.h> typedef long long LL; LL GCD(LL a,LL b){ if(b==0) return a; else return GCD(b,a%b); } int main() { // freopen("input.txt", "r", stdin); int n; LL l, r, w; int remain; scanf("%d", &n); while(n--) { scanf("%lld%lld%lld", &l, &r, &w); LL g=GCD(r,w); if(r+w-g>l) printf("YES\n"); else printf("NO\n"); } return 0; }
C++14 解法, 执行用时: 2ms, 内存消耗: 380KB, 提交时间: 2020-05-20
#include<stdio.h> #include<string.h> typedef long long LL; LL GCD(LL a,LL b){ if(b==0) return a; else return GCD(b,a%b); } int main() { // freopen("input.txt", "r", stdin); int n; LL l, r, w; int remain; scanf("%d", &n); while(n--) { scanf("%lld%lld%lld", &l, &r, &w); LL g=GCD(r,w); if(r+w-g>l) printf("YES\n"); else printf("NO\n"); } return 0; }