<span id="mktg5"></span>

<i id="mktg5"><meter id="mktg5"></meter></i>

        <label id="mktg5"><meter id="mktg5"></meter></label>
        最新文章專題視頻專題問答1問答10問答100問答1000問答2000關鍵字專題1關鍵字專題50關鍵字專題500關鍵字專題1500TAG最新視頻文章推薦1 推薦3 推薦5 推薦7 推薦9 推薦11 推薦13 推薦15 推薦17 推薦19 推薦21 推薦23 推薦25 推薦27 推薦29 推薦31 推薦33 推薦35 推薦37視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關鍵字專題關鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
        問答文章1 問答文章501 問答文章1001 問答文章1501 問答文章2001 問答文章2501 問答文章3001 問答文章3501 問答文章4001 問答文章4501 問答文章5001 問答文章5501 問答文章6001 問答文章6501 問答文章7001 問答文章7501 問答文章8001 問答文章8501 問答文章9001 問答文章9501
        當前位置: 首頁 - 科技 - 知識百科 - 正文

        CodeforcesRound#257(Div.2)題解

        來源:懂視網 責編:小采 時間:2020-11-09 07:58:45
        文檔

        CodeforcesRound#257(Div.2)題解

        CodeforcesRound#257(Div.2)題解:Problem A A. Jzzhu and Children time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output There are n children in Jzzhu's school. Jzzhu is going to give some candies to them. Let's number
        推薦度:
        導讀CodeforcesRound#257(Div.2)題解:Problem A A. Jzzhu and Children time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output There are n children in Jzzhu's school. Jzzhu is going to give some candies to them. Let's number

        Problem A A. Jzzhu and Children time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output There are n children in Jzzhu's school. Jzzhu is going to give some candies to them. Let's number

        Problem A

        A. Jzzhu and Children

        time limit per test

        1 second

        memory limit per test

        256 megabytes

        input

        standard input

        output

        standard output

        There are n children in Jzzhu's school. Jzzhu is going to give some candies to them. Let's number all the children from 1 to n. The i-th child wants to get at least ai candies.

        Jzzhu asks children to line up. Initially, the i-th child stands at the i-th place of the line. Then Jzzhu start distribution of the candies. He follows the algorithm:

        1. Give m candies to the first child of the line.
        2. If this child still haven't got enough candies, then the child goes to the end of the line, else the child go home.
        3. Repeat the first two steps while the line is not empty.

        Consider all the children in the order they go home. Jzzhu wants to know, which child will be the last in this order?

        Input

        The first line contains two integers n,?m (1?≤?n?≤?100; 1?≤?m?≤?100). The second line contains n integers a1,?a2,?...,?an (1?≤?ai?≤?100).

        Output

        Output a single integer, representing the number of the last child.

        Sample test(s)

        input

        5 2
        1 3 1 4 2
        

        output

        4
        

        input

        6 4
        1 1 2 2 3 3
        

        output

        6

        傳送門:點擊打開鏈接

        解體思路:簡單模擬題,用隊列模擬這個過程即可。

        代碼:

        #include 
        #include 
        using namespace std;
        
        typedef pair P;
        queue

        q; int main() { #ifndef ONLINE_JUDGE freopen("257Ain.txt", "r", stdin); #endif int n, m, ans = 0; scanf("%d%d", &n, &m); for(int i = 0; i < n; i++) { int x; scanf("%d", &x); q.push(P(x, i + 1)); } while(!q.empty()) { P p = q.front(); q.pop(); if(p.first > m) { p.first -= m; q.push(p); } ans = p.second; } printf("%d\n", ans); return 0; }


        Problem B

        B. Jzzhu and Sequences

        time limit per test

        1 second

        memory limit per test

        256 megabytes

        input

        standard input

        output

        standard output

        Jzzhu has invented a kind of sequences, they meet the following property:

        You are given x and y, please calculate fn modulo 1000000007 (109?+?7).

        Input

        The first line contains two integers x and y (|x|,?|y|?≤?109). The second line contains a single integer n (1?≤?n?≤?2·109).

        Output

        Output a single integer representing fn modulo 1000000007 (109?+?7).

        Sample test(s)

        input

        2 3
        3
        

        output

        1
        

        input

        0 -1
        2
        

        output

        1000000006

        傳送門:點擊打開鏈接

        解體思路:簡單數學公式的推導,

        f(n) = f(n-1) + f(n+1), f(n+1) = f(n) + f(n+2);

        兩式相加得:f(n-1) + f(n+2) = 0,

        由上式可推得:f(n+2) + f(n+5) = 0;

        由上兩式得:f(n-1) = f(n+5),所以f(n)的周期為6;

        我們只需求出f的前六項即可,ps:注意一點,f(n)可能為負值,對負數取模要先對負數加mod,使負數變為正數之后再取模。

        代碼:

        #include 
        
        const int mod = 1000000007;
        
        int main()
        {
        	#ifndef ONLINE_JUDGE
        	//freopen("257Bin.txt", "r", stdin);
        	#endif
        	int n, a [7];
        	scanf("%d%d%d", &a[0], &a[1], &n);
        	for(int i = 2; i < 7; i++)
        	a[i] = a[i - 1] - a[i - 2];
        	int t = a[(n - 1)% 6];
        	printf("%d\n", t >= 0 ? t % mod : (t + 2 * mod) % mod);
        	return 0;
        }
        

        Problem C

        C. Jzzhu and Chocolate

        time limit per test

        1 second

        memory limit per test

        256 megabytes

        input

        standard input

        output

        standard output

        Jzzhu has a big rectangular chocolate bar that consists of n?×?m unit squares. He wants to cut this bar exactly k times. Each cut must meet the following requirements:

      1. each cut should be straight (horizontal or vertical);
      2. each cut should go along edges of unit squares (it is prohibited to divide any unit chocolate square with cut);
      3. each cut should go inside the whole chocolate bar, and all cuts must be distinct.
      4. The picture below shows a possible way to cut a 5?×?6 chocolate for 5 times.

        Imagine Jzzhu have made k cuts and the big chocolate is splitted into several pieces. Consider the smallest (by area) piece of the chocolate, Jzzhu wants this piece to be as large as possible. What is the maximum possible area of smallest piece he can get with exactly k cuts? The area of a chocolate piece is the number of unit squares in it.

        Input

        A single line contains three integers n,?m,?k (1?≤?n,?m?≤?109; 1?≤?k?≤?2·109).

        Output

        Output a single integer representing the answer. If it is impossible to cut the big chocolate k times, print -1.

        Sample test(s)

        input

        3 4 1
        

        output

        6
        

        input

        6 4 2
        

        output

        8
        

        input

        2 3 4
        

        output

        -1

        傳送門:點擊打開鏈接

        解體思路:

        n行m列,在水平方向最多切n-1刀,豎直方向最多切m-1刀,如果k>n+m-2,就是不能切割的情況;我們找出沿水平方向或豎直方向可以切的最多的刀數mx,如果k>mx,我們就現在這個方向切mx刀,剩下的就是要將一條長為(mn+1)巧克力切(k - mx)刀;其他的情況就是要么就是沿著水平方向切k刀,要么就是沿著豎直方向切k刀,取兩者間的大者。

        代碼:

        #include 
        #include 
        #include 
        using namespace std;
        
        int main()
        {
        	int n, m, k;
        	long long ans = -1;
        	cin >> n >> m >> k;
        	if(k > n + m -2)
        	ans = -1;
        	else
        	{
        	int mx = max(n - 1, m - 1);
        	int mn = min(n - 1, m - 1);
        	if(k > mx)
        	ans = (mn + 1) / (k - mx + 1);
        	else
        	ans = max(1ll * n / (k + 1) * m, 1ll * m / (k + 1) * n);
        	}
        	cout << ans << endl;
        	return 0;
        }
        

        聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

        文檔

        CodeforcesRound#257(Div.2)題解

        CodeforcesRound#257(Div.2)題解:Problem A A. Jzzhu and Children time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output There are n children in Jzzhu's school. Jzzhu is going to give some candies to them. Let's number
        推薦度:
        標簽: div round 題解
        • 熱門焦點

        最新推薦

        猜你喜歡

        熱門推薦

        專題
        Top
        主站蜘蛛池模板: 亚洲国产美女精品久久| 亚洲欧洲自拍拍偷精品 美利坚 | 一级毛片a免费播放王色电影 | 国产高清免费观看| 亚洲国产乱码最新视频| 精品久久久久成人码免费动漫| 久久久久亚洲Av无码专| 99视频全部免费精品全部四虎| 久久亚洲AV成人无码| www.免费在线观看| 亚洲国产精品人久久电影| 在线v片免费观看视频| 亚洲精品免费网站| 国产福利免费在线观看| 一级毛片在线免费播放| 亚洲中文字幕无码中文字在线| 日韩电影免费在线观看中文字幕 | 亚洲日韩乱码中文无码蜜桃臀网站 | 成人免费淫片在线费观看| 国产精品亚洲一区二区三区在线观看 | 成年女人毛片免费播放人| 女bbbbxxxx另类亚洲| 亚洲女人被黑人巨大进入| 99久久婷婷免费国产综合精品| 亚洲日韩图片专区第1页| 在线永久免费的视频草莓| 亚洲高清国产拍精品熟女| 在线观看亚洲成人| 亚洲精品视频在线观看免费| 亚洲精华国产精华精华液 | 亚洲蜜芽在线精品一区| 成人免费淫片在线费观看| 国产精品免费在线播放| 亚洲免费闲人蜜桃| 亚洲色欲久久久久综合网| 在线观看免费中文视频| 污污免费在线观看| 亚洲欧洲精品在线| 亚洲av区一区二区三| 四虎最新永久免费视频| 精品国产污污免费网站入口在线 |