結果

問題 No.396 クラス替え
ユーザー vjudge1
提出日時 2025-05-16 15:28:58
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 579 bytes
コンパイル時間 710 ms
コンパイル使用メモリ 65,512 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2025-05-16 15:29:00
合計ジャッジ時間 1,804 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:7:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    7 |     int n,m,x,y;scanf("%d%d%d%d",&n,&m,&x,&y);
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
    
    int n,m,x,y;scanf("%d%d%d%d",&n,&m,&x,&y);
    int numx=x/m,numy=y/m,rnkx=x%m,rnky=y%m;
    int ansx=0,ansy=0;
    if(numx%2==1)
    {
        if(rnkx==0)ansx=m;
        else ansx=m-rnkx+1;
    }
    else
    {
        if(rnkx==0)ansx=1;
        else ansx=rnkx;
    }
    if(numy%2==1)
    {
        if(rnky==0)ansy=m;
        else ansy=m-rnky+1;
    }
    else
    {
        if(rnky==0)ansy=1;
        else ansy=rnky;
    }
    if(ansx%m==ansy%m)printf("YES");
    else printf("NO");
    return 0;
}
0