| Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|
| 149045 | 翁思宸 | 22相差2的数的个数 | C++ | Accepted | 0 MS | 272 KB | 488 | 2026-03-06 19:41:29 |
//1386 22相差2的数的个数 #include<iostream> #include<cstdio> #include<cstring> #include<cmath> using namespace std; int main(){ int n,s=0,t; cin>>n; int a[n+1]; for(int i=1;i<=n;i++){ cin>>a[i]; } for(int i=1;i<=n;i++){ t=0; for(int j=i;j<=n;j++){ if(abs(a[i]-a[j])<=2){ t++; } } if(t>=s){ s=t; } } cout<<s; return 0; }