拼多多第一题

#include<iostream>
#include <math.h>
#include<algorithm>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int res;
    int temp;
    int m;
    int i=0;
    double p;
    res=log(n+3+1)/log(2);
    temp=pow(2,res);
    m=n+3-(temp-1);
    p=m/pow(2,res-2);
    if(p==0)
        cout<<"D";
    if(p>0&&p<=1)
        cout<<"A";
    if(p>1&&p<=2)
        cout<<"B";
    if(p>2&&p<=3)
        cout<<"C";
    if(p>3&&p<=4)
        cout<<"D";

猜你喜欢

转载自blog.csdn.net/zwz2011303359/article/details/81160687
今日推荐