Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- #define ULL unsigned long long
- using namespace std;
- void suma(ULL n,ULL s,ULL pas,ULL &sol) /// Calculez suma recursiv
- {
- if(s<n*n-4)
- s+=pas,sol+=s,s+=pas,sol+=s,suma(n,s,pas-4,sol);
- }
- int main()
- {
- ifstream f("wisp.in");
- ULL n,k;
- f>>n>>k;
- f.close();
- ULL s=1,sol=0,pas=2*(n-1); /// pas=pasul initial
- sol=n*(k-1)+1; /// Corectez valorea pentru k;
- suma(n,s,pas,sol);
- if(n%2==0) /// Pentru n par
- sol+=n*n-1; /// iau in calcul si ultima valoare
- ofstream g("wisp.out");
- g<<sol;
- g.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement