- 题解
元旦赛 智慧数 规律解5:32
- 2024-1-2 20:31:10 @
#include <bits/stdc++.h>
using namespace std;
void PRC(int N)
{
if(N==1) cout<<3;
else if(N==2) cout<<5;
else
{
int N2, r;
N2=(N-1)/3;
r=N-1-N2*3;
int a[3]={4*N2+4, 4*(N2+1)+1, 4*(N2+1)+3};
cout<<a[r];
}
}
int main()
{
int n;
cin>>n;
PRC(n);
return 0;
}
1 comments
-
Eva LV 6 @ 2024-1-3 17:16:24Edited
#include <bits/stdc++.h> using namespace std; int main() { int y,s,j,a; int n; cin >> n; if(n==1 || n==2 || n==3) { if(n==1) cout<<3<<endl; if(n==2)cout<<5<<endl; if(n==3) cout<<7<<endl; } else { a = n-3; //cout << a <<endl; s = n / 3; //s++; //if (s==0) s=1; //cout << s+1 << "组" <<endl; //cout << s << "组" <<endl; y = a % 3; //cout << "第" << y << "个"<<endl; if (y==1) j=0; if (y==2) j=1; if (y==0) j=-1; //cout <<"加"<< j <<endl; cout << 4*(s+1) + j <<endl; } return 0; } //3 5 7 bs //8 9 11 //12 13 15 //16 17 19 //20 21 23 //24 25 27
规律解法
- 1