Codeforces Round #515 (Div. 3)
Posted chunibyo
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Codeforces Round #515 (Div. 3)相关的知识,希望对你有一定的参考价值。
Codeforces Round #515 (Div. 3)
1 #include<bits/stdc++.h> 2 #include<iostream> 3 #include<cstdio> 4 #include<cstdlib> 5 #include<cstring> 6 #include<cmath> 7 #include<algorithm> 8 #include<queue> 9 #include<vector> 10 #include<map> 11 #define lson i<<1 12 #define rson i<<1|1 13 #define LS l,mid,lson 14 #define RS mid+1,r,rson 15 #define mem(a,x) memset(a,x,sizeof(a)) 16 #define gcd(a,b) __gcd(a,b) 17 #define ll long long 18 #define ull unsigned long long 19 #define lowbit(x) (x&-x) 20 #define pb(x) push_back(x) 21 #define enld endl 22 #define mian main 23 #define itn int 24 #define prinft printf 25 #pragma GCC optimize(2) 26 //#pragma comment(linker, "/STACK:102400000,102400000") 27 28 const double PI = acos (-1.0); 29 const int INF = 0x3f3f3f3f; 30 const int EXP = 1e-8; 31 const int N = 1e5 + 5; 32 const int MOD = 1e9 + 7; 33 const int MAXN = 505; 34 35 using namespace std; 36 37 /* 38 4 39 10 2 3 7 40 100 51 51 51 41 1234 1 100 199 42 1000000000 1 1 1000000000 43 */ 44 int n,L,v,l,r; 45 int main() { 46 std::ios::sync_with_stdio(false); 47 cin.tie(NULL); 48 49 while(cin>>n) { 50 while(n--) { 51 cin>>L>>v>>l>>r; 52 cout<<L/v-(r/v-(l-1)/v)<<endl; 53 } 54 } 55 }
1 #include<bits/stdc++.h> 2 #include<iostream> 3 #include<cstdio> 4 #include<cstdlib> 5 #include<cstring> 6 #include<cmath> 7 #include<algorithm> 8 #include<queue> 9 #include<vector> 10 #include<map> 11 #define lson i<<1 12 #define rson i<<1|1 13 #define LS l,mid,lson 14 #define RS mid+1,r,rson 15 #define mem(a,x) memset(a,x,sizeof(a)) 16 #define gcd(a,b) __gcd(a,b) 17 #define ll long long 18 #define ull unsigned long long 19 #define lowbit(x) (x&-x) 20 #define pb(x) push_back(x) 21 #define enld endl 22 #define mian main 23 #define itn int 24 #define prinft printf 25 #pragma GCC optimize(2) 26 //#pragma comment(linker, "/STACK:102400000,102400000") 27 28 const double PI = acos (-1.0); 29 const int INF = 0x3f3f3f3f; 30 const int EXP = 1e-8; 31 const int N = 1e5 + 5; 32 const int MOD = 1e9 + 7; 33 const int MAXN = 2e5+5; 34 35 using namespace std; 36 37 /* 38 8 39 L 1 40 R 2 41 R 3 42 ? 2 43 L 4 44 ? 1 45 L 5 46 ? 1 47 */ 48 int n; 49 char c; 50 int ind; 51 int a[MAXN]; 52 int main() { 53 //std::ios::sync_with_stdio(false); 54 //cin.tie(NULL); 55 56 while(cin>>n) { 57 int l=0,r=1; 58 mem(a,0); 59 while(n--) { 60 cin>>c>>ind; 61 if(c==‘L‘) { 62 a[ind]=l--; 63 } else if(c==‘R‘) { 64 a[ind]=r++; 65 } else { 66 //cout<<a[ind]<<‘ ‘<<a[l+1]<<‘ ‘<<l+1<<endl; 67 cout<<min(a[ind]-(l+1),r-1-a[ind])<<endl; 68 } 69 } 70 71 } 72 }
以上是关于Codeforces Round #515 (Div. 3)的主要内容,如果未能解决你的问题,请参考以下文章
Codeforces Round #292 (Div. 2) C. Drazil and Factorial 515C
Codeforces Round #515 (Div. 3) B. Heaters (贪心)
Codeforces Round #515 (Div. 3) 解题报告(A~E)
Codeforces Round #436 E. Fire(背包dp+输出路径)