提交时间:2023-11-27 13:26:54
运行 ID: 112582
#include<bits/stdc++.h> using namespace std; int cf(int n){ int a,i,s = 1; a = n / 3; for(i = 1;i <= a;i++){ s = s * 3; } return s; } int main(){ int i,n,a; cin>>n; a = cf(n); if(n % 3 == 0){ cout<<cf(n)<<endl; }else if(n == 2){ cout<<"1"<<endl; }else if(n == 3){ cout<<"3"<<endl; }else if(n == 4){ cout<<"4"<<endl; }else if(n == 5){ cout<<"6"<<endl; } else if(n % 3 == 1){ cout<<cf(n) / 3 * 4; }else{ cout<<cf(n) * 2; } }