https://open.kattis.com/problems/stararrangements
#include<bits/stdc++.h>
using namespace std;
int n;
bool check(int i){
for(int j=n/i; j>=1; j--){
if (i*j+(i-1)*j==n) return true;
if (i*j+(i-1)*(j-1)==n) return true;
}
return false;
}
int main(){
cin >> n; cout<<n<<":\n";
for(int i=2; i<=n-1; i++){
if (check(i)) cout<<i<<","<<i-1<<"\n";
if (n%i==0) cout<<i<<","<<i<<"\n";
}
}
Good luck! If you need help please leave a comment :)
No comments:
Post a Comment