WA#4求调
查看原帖
WA#4求调
894380
oliverfg楼主2023/2/26 10:45
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string.h>
#include<set>
#include<string>
#include<map>
#include<iostream>
#include<queue>
#include <unordered_set>
#include<stdlib.h>
typedef long long ll;
using namespace std;
const int Maxn=110;
int w[110],Maxsum=-1,t,Max=-1,V,sum=0,u,v;
long long p;
string s;
ll n,m,ans=0,q;

int main()
{
    int w;
    cin>>w>>m>>n;
    int dhm=ceil((double)m/(double)w);
    int dhn=ceil((double)n/(double)w);
    int v=abs(dhm-dhn);
    
        if(dhm%2==0&&dhn%2==0)
        {
            int t1=m%w;
            int t2=n%w;
            int h=abs(t1-t2);
            ans=h+v;
        }    
        else if(dhm%2!=0&&dhn%2==0)
        {
            int t1=m%w;
            int t2=n%w;
            t2=w-t2;
            int h=abs(t1-t2)+1;
            ans=h+v;
        }
        else if(dhm%2==0&&dhn%2!=0)
        {
            int t1=m%w;
            int t2=n%w;
            t1=w-t1;
            int h=abs(t1-t2)+1;
            ans=h+v;
        }
        else
        {
            int t1=m%w;
            int t2=n%w;
            int h=abs(t1-t2);
            ans=h+v;
        }
    cout<<ans;
    system("pause");
    return 0;
}


2023/2/26 10:45
加载中...