首頁 web前端 html教學 Codeforces Round #276 (Div. 2) 解题报告_html/css_WEB-ITnose

Codeforces Round #276 (Div. 2) 解题报告_html/css_WEB-ITnose

Jun 24, 2016 am 11:54 AM

题目地址:http://codeforces.com/contest/485

A题:Factory

按照过程模拟,并判断是否出现循环,如果出现循环,说明肯定不可能,直接跳出。

代码如下:

#include <iostream>#include <stdio.h>#include <string.h>#include <algorithm>using namespace std;int _hash[100001];int main(){    int a, m, i, flag=0;    memset(_hash,0,sizeof(_hash));    scanf("%d%d",&a,&m);    a=a%m;    _hash[a]=1;    while(1)    {        a=a*2%m;        if(a==0)        {            flag=1;            break;        }        if(_hash[a])        {            break;        }        _hash[a]=1;    }    if(!flag) puts("No");    else        puts("Yes");    return 0;}</algorithm></string.h></stdio.h></iostream>
登入後複製

B题:Valuable Resources

直接找行与列的最大值和最小值,不多说

代码如下:

#include <iostream>#include <cstdio>#include <string>#include <cstring>#include <stdlib.h>#include <math.h>#include <ctype.h>#include <queue>#include <map>#include <set>#include <algorithm>using namespace std;#define LL __int64const LL INF=1e11;int main(){    LL n, x, y, max1, max2, min1, min2, s;    while(scanf("%I64d",&n)!=EOF)    {        max1=-INF;        max2=-INF;        min1=INF;        min2=INF;        while(n--)        {            scanf("%I64d%I64d",&x,&y);            max1=max(max1,x);            max2=max(max2,y);            min1=min(min1,x);            min2=min(min2,y);        }        s=max(max1-min1,max2-min2);        s*=s;        printf("%I64d\n",s);    }    return 0;}</algorithm></set></map></queue></ctype.h></math.h></stdlib.h></cstring></string></cstdio></iostream>
登入後複製

C题:Bits

贪心

从小的开始,不断从低位开始加1,直到大于较大数为止。

代码如下:

#include <iostream>#include <cstdio>#include <string>#include <cstring>#include <stdlib.h>#include <math.h>#include <ctype.h>#include <queue>#include <map>#include <set>#include <algorithm>using namespace std;#define LL __int64const LL INF=1e11;int s[1000];int main(){    int n, len, max1;    LL x, y, z1, z, i;    scanf("%d",&n);    while(n--)    {        scanf("%I64d%I64d",&x,&y);        z1=x;        len=0;        memset(s,0,sizeof(s));        while(z1)        {            s[len++]=z1%2;            z1/=2;        }        z=x;        for(i=0;iy)                {                    printf("%I64d\n",z);                    break;                }                z=x;            }        }    }    return 0;}</algorithm></set></map></queue></ctype.h></math.h></stdlib.h></cstring></string></cstdio></iostream>
登入後複製

D题:Maximum Value

对于x来说,在k*x~(k+1)*x这段范围内,余数最大的肯定是最接近(k+1)*x的数,所以可以预处理出来所有最接近当前数的数,然后分别枚举每个数的倍数,并不断更新即可。

代码如下:

#include <iostream>#include <cstdio>#include <string>#include <cstring>#include <stdlib.h>#include <math.h>#include <ctype.h>#include <queue>#include <map>#include <set>#include <algorithm>using namespace std;#define LL __int64const int INF=0x3f3f3f3f;int _hash[2100000], dp[2100000], a[2100000];int main(){    int n, i, j, x, min1, ans, max1;    while(scanf("%d",&n)!=EOF)    {        memset(_hash,0,sizeof(_hash));        min1=INF;        max1=-1;        for(i=0; i<n i scanf _hash min1="min(min1,x);" max1="max(max1,x);" for if dp else ans="0;" j continue break printf return>  <br>  <br>  <p></p> </n></algorithm></set></map></queue></ctype.h></math.h></stdlib.h></cstring></string></cstdio></iostream>
登入後複製
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

AI Hentai Generator

AI Hentai Generator

免費產生 AI 無盡。

熱門文章

R.E.P.O.能量晶體解釋及其做什麼(黃色晶體)
3 週前 By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.最佳圖形設置
3 週前 By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.如果您聽不到任何人,如何修復音頻
3 週前 By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25:如何解鎖Myrise中的所有內容
3 週前 By 尊渡假赌尊渡假赌尊渡假赌

熱工具

記事本++7.3.1

記事本++7.3.1

好用且免費的程式碼編輯器

SublimeText3漢化版

SublimeText3漢化版

中文版,非常好用

禪工作室 13.0.1

禪工作室 13.0.1

強大的PHP整合開發環境

Dreamweaver CS6

Dreamweaver CS6

視覺化網頁開發工具

SublimeText3 Mac版

SublimeText3 Mac版

神級程式碼編輯軟體(SublimeText3)

&gt; gt;的目的是什麼 元素? &gt; gt;的目的是什麼 元素? Mar 21, 2025 pm 12:34 PM

本文討論了HTML&lt; Progress&gt;元素,其目的,樣式和與&lt; meter&gt;元素。主要重點是使用&lt; progress&gt;為了完成任務和LT;儀表&gt;對於stati

&lt; datalist&gt;的目的是什麼。 元素? &lt; datalist&gt;的目的是什麼。 元素? Mar 21, 2025 pm 12:33 PM

本文討論了html&lt; datalist&gt;元素,通過提供自動完整建議,改善用戶體驗並減少錯誤來增強表格。Character計數:159

&lt; meter&gt;的目的是什麼。 元素? &lt; meter&gt;的目的是什麼。 元素? Mar 21, 2025 pm 12:35 PM

本文討論了HTML&lt; meter&gt;元素,用於在一個範圍內顯示標量或分數值及其在Web開發中的常見應用。它區分了&lt; meter&gt;從&lt; progress&gt;和前

HTML5中跨瀏覽器兼容性的最佳實踐是什麼? HTML5中跨瀏覽器兼容性的最佳實踐是什麼? Mar 17, 2025 pm 12:20 PM

文章討論了確保HTML5跨瀏覽器兼容性的最佳實踐,重點是特徵檢測,進行性增強和測試方法。

視口元標籤是什麼?為什麼對響應式設計很重要? 視口元標籤是什麼?為什麼對響應式設計很重要? Mar 20, 2025 pm 05:56 PM

本文討論了視口元標籤,這對於移動設備上的響應式Web設計至關重要。它解釋瞭如何正確使用確保最佳的內容縮放和用戶交互,而濫用可能會導致設計和可訪問性問題。

我如何使用html5&lt; time&gt; 元素以語義表示日期和時間? 我如何使用html5&lt; time&gt; 元素以語義表示日期和時間? Mar 12, 2025 pm 04:05 PM

本文解釋了HTML5&lt; time&gt;語義日期/時間表示的元素。 它強調了DateTime屬性對機器可讀性(ISO 8601格式)的重要性,並在人類可讀文本旁邊,增強Accessibilit

如何使用HTML5表單驗證屬性來驗證用戶輸入? 如何使用HTML5表單驗證屬性來驗證用戶輸入? Mar 17, 2025 pm 12:27 PM

本文討論了使用HTML5表單驗證屬性,例如必需的,圖案,最小,最大和長度限制,以直接在瀏覽器中驗證用戶輸入。

&lt; iframe&gt;的目的是什麼。 標籤?使用時的安全考慮是什麼? &lt; iframe&gt;的目的是什麼。 標籤?使用時的安全考慮是什麼? Mar 20, 2025 pm 06:05 PM

本文討論了&lt; iframe&gt;將外部內容嵌入網頁,其常見用途,安全風險以及諸如對象標籤和API等替代方案的目的。

See all articles