Codeforces Round #515 (Div. 3) A. Vova and Train
題解
題目大意 總長度為L 每到v的倍數位置都有一個路燈 現有一火車在[l, r]問在火車遮擋後 能看見多少個路燈
(r - 1) / v計算左側出現路燈數量L / v - r / v計算右側出現路燈數量
AC 程式碼
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
int main()
{
#ifdef LOCAL
//freopen("C:/input.txt", "r", stdin);
#endif
int T;
cin >> T;
while (T--)
{
int L, v, l, r;
cin >> L >> v >> l >> r;
int ans = (l - 1) / v + L / v - r / v;
cout << ans << endl;
}
return 0;
}
相關推薦
Codeforces Round #515 (Div. 3)A. Vova and Train【水題】
A. Vova and Train time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vova
Codeforces Round #515 (Div. 3) A. Vova and Train
題解 題目大意 總長度為L 每到v的倍數位置都有一個路燈 現有一火車在[l, r]問在火車遮擋後 能看見多少個路燈 (r - 1) / v計算左側出現路燈數量L / v - r / v計算右側出現路燈數量 AC 程式碼 #include <stdio.h&
Codeforces Round #515 (Div. 3) A(思維)
題意:找1~L之間 v 的倍數的個數,在區間[l,r]之間的不能算 思路:1到n之間v的倍數個數為n/v向下取整,因為是閉區間,所以區間裡v的倍數個數為r/v-(l-1)/v,l為什麼要減一?因為l-1/v是1到l-1中v的倍數個數。 #include<bits/stdc++.h>
Codeforces Round #515 (Div. 3) A、B、C、D
A. Vova and Train time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vo
Codeforces Round #515 (Div. 3) A、B、C、D
A. Vova and Train time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vova
A. Vova and Train ( Codeforces Round #515 (Div. 3) )
題意:一條 L 長的路,一列車長在這條路的 l 到 r 之間,只有在 v 倍數時有燈,但是在 l 到 r 之間的燈是看不見的,問最大看見的燈的個數? 題解:L / v 表示總共的燈的個數, r / v 、( l - 1 ) / v 表示前 r 、( l - 1 ) 長的路有多少燈,
Codeforces Round #515 (Div. 3) E. Binary Numbers AND Sum
由題意可以知道a&b產生的值對答案有m次貢獻,按次算貢獻值是肯定超時的,所以按位算貢獻,觀察可以發現只有a這個二進位制數裡的1對答案有貢獻,貢獻值為pre[i]*這個1對應的值(即假如這個1是第i為,則這個1對應的值就是2^(i-1)),pre[i]表示二進位制數b第i位及
Codeforces Round #515 (Div. 3)E. Binary Numbers AND Sum【數學】
E. Binary Numbers AND Sum time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output
Codeforces Round #417 (Div. 2) A. Sagheer and Crossroads 模擬 枚舉
ces color 一次 name exit main cst space amp Codeforces Round #417 (Div. 2) A. Sagheer and Crossroads 模擬 枚舉 題意 一個紅綠燈 按逆時針方向一次給出各個路口的左轉,
【貪心】 Codeforces Round #419 (Div. 1) A. Karen and Game
blog true 刪除 round 貪心 cnblogs pac names namespace 容易發現,刪除的順序不影響答案。 所以可以隨便刪。 如果行數大於列數,就先刪列;否則先刪行。 #include<cstdio> #include<algo
Codeforces Round #396(Div. 2) A. Mahmoud and Longest Uncommon Subsequence
color HA \n seq 字符 turn ces DC %s 【題意概述】 找兩個字符串的最長不公共子串。 【題目分析】 兩個字符串的最長不公共子串就應該是其中一個字符串本身,那麽判斷兩個字符串是否相等,如果相等,那麽肯定沒有公共子串,輸出“-1”.否則就
Codeforces Round #417 (Div. 2)-A. Sagheer and Crossroad
sca \n ret name nbsp style can turn ros 【題意概述】 在一個十字路口 ,給定紅綠燈的情況, 按逆時針方向一次給出各個路口的左轉,直行,右轉,以及行人車道,判斷汽車是否有可能撞到行人 【題目分析】 需要在邏輯上清晰
Codeforces Round #486 (Div. 3) A. Diverse Team
pre table ngs href AI pop ons NPU school Codeforces Round #486 (Div. 3) A. Diverse Team 題目連接: http://codeforces.com/contest/988/problem/
Codeforces Round #486 (Div. 3) D. Points and Powers of Two
equals tegra names size AR tin ++ include ESS Codeforces Round #486 (Div. 3) D. Points and Powers of Two 題目連接: http://codeforces.com/gro
Codeforces Round #501 (Div. 3) A Points in Segments
segments ble round show 默認 () for using pre 翻譯 現在有一個數軸,上面會有\(M\)個點,標號為\(1\)到\(N\),現在給你在數軸上的條\(N\)線段的起始與終止的點,問哪幾個點沒有被這樣線段覆蓋,從小到大輸出。 思路 簽到題
Codeforces Round #515 (Div. 3)
mat queue min src rain d+ round () 圖片 Codeforces Round #515 (Div. 3) 1 #include<bits/stdc++.h> 2 #include<iostream> 3 #i
Codeforces Round #515 (Div. 3) D. Boxes Packing
比賽的時候這題的題意一直沒看懂,後面才明白意思就是有n個物品,然後要求最多可以挑選出多少物品,挑選過程是從第一給物品開始往右邊挑選,對於每一個物品,如果目前的盒子剩餘空間是>=該物品的體積的就直接放進盒子,繼續挑選下一個物品,若目前的盒子剩餘空間是<該物
Codeforces Round #293 (Div. 2)A. Vitaly and Strings
這題非常有意思,各種HACk - - ,給HACK後正場比賽都。。。。。還花了大把的時間去改,還WA ,水平太差 題目連線:http://codeforces.com/contest/518/problem/A 題意:給出兩個字串s、t (t字典序比s大),問有沒有字典序在s 和t 之間的字
Codeforces Round #515 (Div. 3) B(模擬)
題意:在數列中值為1的位置有1個加熱器,它能覆蓋它的左邊第 r-1 位置到它的右邊 r-1 的位置,問最少多少個加熱器能覆蓋整個區間。 思路:模擬這個過程,首先now=1,然後遍歷所有位置,找到最遠的滿足now這個位置能加熱的點,再另now=i+r-1+1,之所以要+1,是因為,i+r-1這個位
Codeforces Round #515 (Div. 3) E(模擬+字首和)
題意:a和b是兩個01字串,現要計算a&b+a&b>>1+a&b>>2+……(直到b=0) 思路: 因為a和b的長度不確定,所以給短的那個在前面補上0,因為b每一次往右移,所以可以計算b的每一位上的貢獻,這個貢獻就是這一位及前面一共有多少1,為什麼