• <input id="auww4"></input>
  • <input id="auww4"><acronym id="auww4"></acronym></input>
  • <input id="auww4"><u id="auww4"></u></input>
    <object id="auww4"><acronym id="auww4"></acronym></object>
    <menu id="auww4"></menu><input id="auww4"><u id="auww4"></u></input>
    <input id="auww4"><u id="auww4"></u></input>
  • F.A.Q
    Hand In Hand
    Online Acmers
    Forum | Discuss
    Statistical Charts
    Problem Archive
    Realtime Judge Status
    Authors Ranklist
     
         C/C++/Java Exams     
    ACM Steps
    Go to Job
    Contest LiveCast
    ICPC@China
    Best Coder beta
    VIP | STD Contests
    Virtual Contests
        DIY | Web-DIY beta
    Recent Contests
    Author ID 
    Password 
     Register new ID

    Re:等差數列求和公式。。。。。學到了!C ac

    Posted by HongyangHU at 2019-03-04 15:35:08 on Problem 2058
    (42)  


    #include <stdio.h>
    #include <stdlib.h>
    #include <math.h>
    /* run this program using the console pauser or add your own getch, system("pause") or input loop */
    
    int main(int argc, char *argv[]) {
    	int n,m;
    	while(scanf("%d%d",&n,&m)!=EOF){
    		if(n==0&&m==0)
    		break;
    		int i;
    		for(i=sqrt(2*m);i>0;--i){
    		int  a=(m-(i*(i-1))/2)/i;//求首項整數,項數已知
    		if(m==a*i+i*(i-1)/2&&a>0)//根據這個首項算是否和為m
    		printf("[%d,%d]n",a,a+i-1);
    		}
    		printf("n");
    	} 
    	return 0;
    }


    Post your reply here:

    Author ID
    Password
    Title
    Content  
     
    Hangzhou Dianzi University Online Judge 3.0
    Copyright © 2005-2020 HDU ACM Team. All Rights Reserved.
    Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
    Total 0.000000(s) query 4, Server time : 2020-11-09 02:27:33, Gzip enabled
    棋牌