Advertisement
mihaimarcel21

formula1_eu

Mar 26th, 2021
532
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.48 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4. ifstream fin("formula1.in");
  5. ofstream fout("formula1.out");
  6. int C, N, K;
  7. long long sol, suma;
  8. int main()
  9. {
  10.     fin>>C>>K>>N;
  11.     if(C==1)
  12.     {
  13.         sol=1LL*(2*K-1)*(2*K-1);
  14.         fout<<sol;
  15.         return 0;
  16.     }
  17.     for(int i=1; i<=N; i++)
  18.     {
  19.         sol=1LL*2*i*i-2*i;
  20.         suma+=sol;
  21.     }
  22.     sol=(long long)sqrtl(1LL*2*suma+1);
  23.     if(sol%2==0)
  24.         sol--;
  25.     fout<<sol*sol;
  26.     return 0;
  27. }
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement