第一题只过了45%,求帮看看问题 = =。 #include<iostream> #include<vector> using namespace std; int main() { int t; cin >> t; int N; for (int i = 0;i<t;++i) { vector<int>num; int Result = 0; cin >> N; for (int i = 0;i < A;++i) { num.push_back(0); } int sum = 4 * N; if (N == 0) { Result = 0; } else if (N == 1) { Result = 2; } else if (N == 3) { Result = 3; } else { for (int i = 1;i < sum + 1;++i) { int x = ((N + 1)*i) % sum; if (num[x] == 1) { Result++; break; } else if (num[x] == 0) { num[x] = 1; Result++; } } } cout << Result << endl; } }
t=int(input())
a=list(map(int,input().split()))
def gcd(m,n):
while m*n!=0:
m%=n
if m==0:
return n
else:
n%=m
if n==0:
return m
for i in range(t):
x=gcd(4*a[i],a[i]+1)
print(4*a[i]//x+1)
第一题.27 死活没想明白为啥8*8时结果是33 直接n*4+1算的 a=int(input()) d=input() line=[] line2=[] b=0 c=0 if a>1000: print('error') else: line=[int(n) for n in d.split()] for i in range(0,1000): b=line[i] c=b*4+1 print(c)