hdoj2012

平行线不会相交 平行线不会相交     2022-09-18     684

关键词:

 半夜睡不着起来A了一道水题,关于素数判定。判定素数的主要思路是 int a,判断a/j*j是否等于a,利用的是整型相除会舍去小数部分。其中j从2到a/2。还有设置标记变量,一旦发现非素数就跳出循环,且用来判断区间内对应数是否全为素数。好吧,素数判断a%j是否为0就可以了,绕了一圈。
#include<iostream>
int main()
{
    using namespace std;
    int x, y;
    while (cin >> x >> y && (x!=0 || y!=0))
    {
        int k = 1;
        for (int i = x; i <= y; i++)
        {
            int a = i * i + i + 41;
            for (int j = 2; j <= a/2; j++)
            {
                if(a/j*j == a){
                    k = 0;
                    break;
                } 
            }
            if (k == 0) break;
            
        }
        if(k) cout << "OK
";
        else cout << "Sorry
";
    }
    return 0;
 } 

 

hdoj3339

原题链接描述Since1945,whenthefirstnuclearbombwasexplodedbytheManhattanProjectteamintheUS,thenumberofnuclearweaponshavesoaredacrosstheglobe.Nowadays,thecrazyboyinFZUnamedAekdyCoinpossessessomenuclearweaponsa 查看详情

hdoj1247

原题链接描述Ahat’swordisawordinthedictionarythatistheconcatenationofexactlytwootherwordsinthedictionary.Youaretofindallthehat’swordsinadictionary.输入Standardinputconsistsofanumberoflowercasewords,oneperline, 查看详情

hdoj1014

ProblemDescriptionComputersimulationsoftenrequirerandomnumbers.Onewaytogeneratepseudo-randomnumbersisviaafunctionoftheformseed(x+1)=[seed(x)+STEP]%MODwhere‘%‘isthemodulusoperator.Suchafunctionwillgene 查看详情

hdoj1002

问题描述Ihaveaverysimpleproblemforyou.GiventwointegersAandB,yourjobistocalculatetheSumofA+B.输入描述ThefirstlineoftheinputcontainsanintegerT(1<=T<=20)whichmeansthenumberoftestcases.ThenTlinesfollow,each 查看详情

hdoj的题目分类

模拟题,枚举10021004101310151017102010221029103110331034103510361037103910421047104810491050105710621063106410701073107510821083108410881106110711131117111911281129114411481157116111701172117711971200120112 查看详情

hdoj1671

原题链接描述Givenalistofphonenumbers,determineifitisconsistentinthesensethatnonumberistheprefixofanother.Let’ssaythephonecataloguelistedthesenumbers:Emergency911Alice97625999Bob91125426Inthiscase,it’snotpos 查看详情

hdoj1008

ElevatorTimeLimit:2000/1000MS(Java/Others)MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):25560AcceptedSubmission(s):13793ProblemDescriptionThehighestbuildinginourcityhasonlyoneelevator.Areque 查看详情

hdoj1013

DigitalRootsTimeLimit:2000/1000MS(Java/Others)MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):30962AcceptedSubmission(s):9508ProblemDescriptionThedigitalrootofapositiveintegerisfoundbysummingt 查看详情

hdoj4812dtree

DiscriptionThereisaskyscrapingtreestandingontheplaygroundofNanjingUniversityofScienceandTechnology.Oneachbranchofthetreeisaninteger(ThetreecanbetreatedasaconnectedgraphwithNvertices,whileeachbranchcan 查看详情

hdoj2058

原题链接描述Givenasequence1,2,3,......N,yourjobistocalculateallthepossiblesub-sequencesthatthesumofthesub-sequenceisM.输入Inputcontainsmultipletestcases.eachcasecontainstwointegersN,M(1<=N,M<=1000000000 查看详情

hdoj2062

原题链接描述ConsidertheaggregateAn={1,2,…,n}.Forexample,A1={1},A3={1,2,3}.Asubsetsequenceisdefinedasaarrayofanon-emptysubset.SortallthesubsetsequeceofAninlexicographyorder.Yourtaskistofindthem-thone.输入Thein 查看详情

hdoj1012

水题天天有,今天特别多....嘿嘿uCalculateeTimeLimit:2000/1000MS(Java/Others)MemoryLimit:65536/32768K(Java/Others)TotalSubmission(s):19289AcceptedSubmission(s):8423ProblemDescriptionAsimplemathematicalformulaforeisw 查看详情

hdoj3746cyclicnacklace

ProblemDescriptionCCalwaysbecomesverydepressedattheendofthismonth,hehascheckedhiscreditcardyesterday,withoutanysurprise,thereareonly99.9yuanleft.heistoodistressedandthinkingabouthowtotideoverthelastda 查看详情

hdoj2009求数列的和(代码片段)

ProblemDescription数列的定义如下:数列的第一项为n,以后各项为前一项的平方根,求数列的前m项的和。  Input输入数据有多组,每组占一行,由两个整数n(n<10000)和m(m<1000)组成,n和m的含义如前所述。  Output对... 查看详情

hdoj:2069

CoinChangeTimeLimit:1000/1000MS(Java/Others)   MemoryLimit:32768/32768K(Java/Others)TotalSubmission(s):18271   AcceptedSubmission(s):6291ProblemDescriptionSupposethereare 查看详情

hdoj:2070

FibbonacciNumberTimeLimit:1000/1000MS(Java/Others)   MemoryLimit:32768/32768K(Java/Others)TotalSubmission(s):22530   AcceptedSubmission(s):10375ProblemDescriptionYourobje 查看详情

hdoj3351-stack

ProblemDescriptionI’moutofstories.ForyearsI’vebeenwritingstories,somerathersilly,justtomakesimpleproblemslookdifficultandcomplexproblemslookeasy.But,alas,notforthisone.You’regivenanonemptystringmadein 查看详情

hdoj:2071

MaxNumTimeLimit:1000/1000MS(Java/Others)   MemoryLimit:32768/32768K(Java/Others)TotalSubmission(s):22270   AcceptedSubmission(s):13029ProblemDescriptionTherearesomestuden 查看详情