제출 #1068725

#제출 시각아이디문제언어결과실행 시간메모리
1068725alexddStrange Device (APIO19_strange_device)C++17
10 / 100
5007 ms524288 KiB
#include<bits/stdc++.h>
using namespace std;
#define int long long
int gcd(int x, int y)
{
    while(x>0)
    {
        int r = y%x;
        y=x;
        x=r;
    }
    return y;
}
map<pair<int,int>,int> mp;
signed main()
{
    int n,A,B,cnt=0,B1;
    cin>>n>>A>>B;
    int gc = gcd(A,B+1);
    A /= gc;
    B1 = (B+1)/gc;
    int le,ri;
    for(int i=1;i<=n;i++)
    {
        cin>>le>>ri;
        for(int t=le;t<=ri;t++)
        {
            int p = t/B;
            pair<int,int> aux = {p%A, t%B};
            if(mp[aux]==0)
            {
                mp[aux]++;
                cnt++;
            }
        }
    }
    cout<<cnt;
    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

strange_device.cpp: In function 'int main()':
strange_device.cpp:17:21: warning: variable 'B1' set but not used [-Wunused-but-set-variable]
   17 |     int n,A,B,cnt=0,B1;
      |                     ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...