답안 #987301

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
987301 2024-05-22T14:15:19 Z 0pt1mus23 Intercastellar (JOI22_ho_t1) C++14
100 / 100
68 ms 7568 KB
#pragma GCC optimize("O3","inline")
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(),v.end()
#define ins insert
#define pb push_back
#define int long long
#define pii pair<int,int>
#define endl '\n'
#define drop(x) cout<<(x)<<endl;return;
#define reach cerr<<"reached >.<!"<<endl;
/*
    m : 11059739 -> l ~23
    p : 4567896467
*/
// mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const int mod =  1e9 +7, sze=2e5 +5,inf=LLONG_MAX, prime = 2333;

//\\
:pepeblacklove:  :dp/st/sp/bs/gr: :pepeblacklove:  
//

void gkd(){
    int n;
    cin>>n;
    vector<int> arr(n+1);
    for(int i=0;i<n;i++){
        cin>>arr[i+1];
    }
    int q;cin>>q;
    int last = 0;
    int i =1;
    while(q--){
        int x;
        cin>>x;
        int ans=0;
        while(last<=x){
            int ihave = (arr[i]%2?1:0);
            if(!ihave){

                int l = 1;
                int r = 30;
                int bolgu=0;
                while(l<=r){
                    int mid = (l+r)/2;
                    // cout<<arr[i]<< " "<<(1<<mid)<<endl;
                    if(arr[i]% ( 1<<mid ) ==0){
                        bolgu = (1<<mid);
                        l=mid+1;
                    }
                    else{
                        r=mid-1;
                    }
                }

                ihave = bolgu;
            }
            // cout<<last<<" "<<ihave<<endl;
            if(last+ihave<x){
                last+=ihave;
                i++;
            }
            else{
                // cout<<arr[i]<< " "<<ihave<<endl;
                ans = arr[i]/ihave;
                break;
            }
        }
        cout<<ans<<endl;
    }
}

signed main(){
    cin.tie(0)->sync_with_stdio(0);
    int tt=1; 
    // cin>>tt;
    while(tt--) gkd();
    
    return 0;
}

Compilation message

Main.cpp:19:1: warning: multi-line comment [-Wcomment]
   19 | //\\
      | ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 16 ms 2652 KB Output is correct
4 Correct 22 ms 2128 KB Output is correct
5 Correct 41 ms 3924 KB Output is correct
6 Correct 29 ms 2776 KB Output is correct
7 Correct 41 ms 4136 KB Output is correct
8 Correct 39 ms 4168 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 16 ms 2652 KB Output is correct
4 Correct 22 ms 2128 KB Output is correct
5 Correct 41 ms 3924 KB Output is correct
6 Correct 29 ms 2776 KB Output is correct
7 Correct 41 ms 4136 KB Output is correct
8 Correct 39 ms 4168 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 22 ms 2904 KB Output is correct
24 Correct 29 ms 4176 KB Output is correct
25 Correct 61 ms 7252 KB Output is correct
26 Correct 42 ms 4716 KB Output is correct
27 Correct 39 ms 4440 KB Output is correct
28 Correct 68 ms 7568 KB Output is correct
29 Correct 55 ms 7172 KB Output is correct
30 Correct 34 ms 3668 KB Output is correct
31 Correct 64 ms 7500 KB Output is correct