Cod sursa(job #2552473)

Utilizator bem.andreiIceman bem.andrei Data 20 februarie 2020 21:11:51
Problema Pascal Scor 10
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 1.49 kb
#include <iostream>
#include <fstream>

using namespace std;
ifstream R("pascal.in");
ofstream w("pascal.out");
int v[5000001];
int main()
{
    int r, d, put=0, cnt=0;
    R>>r>>d;
    if(d==2)
    {
        for(int i=2; i<=r; i++)
        {
            v[i]=v[i/2]+1;
        }
        for(int i=1;i<=r/2;i++){
            put=put+v[r-i+1]-v[i];
            if(put!=0){
                cnt++;
            }
        }
    }
    else if(d==3)
    {
        for(int i=3; i<=r; i++)
        {
            v[i]=v[i/3]+1;
        }
        for(int i=1;i<=r/2;i++){
            put=put+v[r-i+1]-v[i];
            if(put!=0){
                cnt++;
            }
        }
    }
    else if(d==4)
    {
        for(int i=4; i<=r; i++)
        {
            v[i]=v[i/4]+1;
        }
        for(int i=1;i<=r/2;i++){
            put=put+v[r-i+1]-v[i];
            if(put!=0){
                cnt++;
            }
        }
    }
    else if(d==5)
    {
        for(int i=5; i<=r; i++)
        {
            v[i]=v[i/5]+1;
        }
        for(int i=1;i<=r/2;i++){
            put=put+v[r-i+1]-v[i];
            if(put!=0){
                cnt++;
            }
        }
    }
    else if(d==6)
    {
        for(int i=6; i<=r; i++)
        {
            v[i]=v[i/6]+1;
        }
        for(int i=1;i<r/2;i++){
            put=put+v[r-i+1]-v[i];
            if(put!=0){
                cnt++;
            }
        }
    }
    w<<cnt*2;
    return 0;
}