답안 #721644

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
721644 2023-04-11T06:05:02 Z victor_gao 이상한 기계 (APIO19_strange_device) C++17
0 / 100
5000 ms 1236 KB
//#pragma GCC optimize("Ofast,unroll-loops,O3")
//#pragma GCC optimize("avx,avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,fma,tune=native")
#include<bits/stdc++.h>
//#include<bits/extc++.h>
//#pragma pack(1)
#define fast ios::sync_with_stdio(0); cin.tie(0);
#define int long long
#define pii pair<int,int>
#define x first
#define y second
using namespace std;
//using namespace __gnu_pbds;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//typedef tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update> order_multiset;
//typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> order_set;
int findt(int a,int b){
    int go=b+1,g=__gcd(go,a);
   // cout<<go<<" "<<a<<' '<<b<<" "<<g<<'\n';
    // lcm(go,a)/go*b
    if ((double)(log10(a/g)+log10(b))>=18.0001) return 2e18;
    else return a/g*b;
}
bool vis[1500000];
signed main(){
    fast
    int n,a,b; cin>>n>>a>>b;
    int t=findt(a,b);
    if (t>1100000){
        int ans=0;
        for (int i=1;i<=n;i++){
            int l,r; cin>>l>>r;
            ans+=(r-l+1);
        }
        cout<<ans<<'\n';
    }
    else {
        for (int i=1;i<=n;i++){
            int l,r; cin>>l>>r;
            l%=t; r%=t;
            if (l<=r){
                for (int j=l;j<=r;j++)
                    vis[j]=1;
            }
            else {
                for (int j=0;j<=r;j++)
                    vis[j]=1;
                for (int j=l;j<t;j++)
                    vis[j]=1;
            }
        }
        int ans=0;
        for (int i=0;i<1500000;i++)
            ans+=vis[i];
        cout<<ans<<'\n';
    }
    
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 3 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 2 ms 1108 KB Output is correct
3 Correct 2 ms 1108 KB Output is correct
4 Correct 2 ms 980 KB Output is correct
5 Execution timed out 5056 ms 1236 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 289 ms 312 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 289 ms 312 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 289 ms 312 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 33 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 3 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -