NC20674. 死肥宅的冲分计划
描述
输入描述
多组输入,每行输入10个数字,只包含1,0,7,三个数字。
输出描述
10天后如果死肥宅的段位达到王者,输出"666";否则输出"777"。
示例1
输入:
7 7 7 7 7 7 7 7 7 7 1 1 1 1 1 1 1 1 1 1
输出:
777 666
C(clang 3.9) 解法, 执行用时: 59ms, 内存消耗: 604K, 提交时间: 2018-11-17 14:28:34
#include<stdio.h> int main() { int i,m,a[13]; while(scanf("%d",a)!=EOF) { for(i=1;i<10;i++) { scanf("%d",&a[i]); } m=3; for(i=0;i<10;i++) { if(m!=1&&a[i]==7) m--; if(m!=7&&a[i]==1) m++; } if(m>=7)printf("666\n"); else printf("777\n"); } return 0; }
C++11(clang++ 3.9) 解法, 执行用时: 44ms, 内存消耗: 504K, 提交时间: 2020-07-21 19:15:12
#include<bits/stdc++.h> using namespace std; int main() { int c=0,a,ans=3; while(~scanf("%d",&a)) { c++; if(a==1&&ans<7)ans++; if(a==7&&ans>1)ans--; if(c==10) { if(ans==7)printf("666\n"); else printf("777\n"); ans=3,c=0; } } return 0; }
Python3(3.5.2) 解法, 执行用时: 366ms, 内存消耗: 4052K, 提交时间: 2020-07-21 19:34:43
import sys; for s in sys.stdin: a = list(map(int, s.split())) level = 3 for v in a: if v == 1: level = min(level + 1, 7) elif v == 7: level = max(level - 1, 1) print("666" if level == 7 else "777")