#29584:


e3524167 (Kenlogin)

學校 : 不指定學校
編號 : 186743
來源 : [182.233.207.92]
最後登入時間 :
2022-03-17 21:12:56
a059. 完全平方和 | From: [182.233.207.92] | 發表日期 : 2022-03-13 03:06

#include <iostream>

#include <string> 

#include <sstream>

using namespace std;

int pow(int a); //計算平方

int main()

{

int x;

while (cin >> x)

{

int a, b,lenght=0,lenght2=0;

int res[1000];

int out[100];

int n=0;

for (int i = 0; i < x; i++)

{

cin >> a >> b;

res[0 + i*2] = a;

res[1 + i*2] = b;

lenght = lenght + 1;

}

for (int i = 0; i < lenght; i++)

{

for (int j = 0; j < res[1 + i * 2]; j++)

{

if (res[0 + i * 2] <= pow(j) && res[1 + i * 2] >= pow(j))

{

n = n + pow(j);

}

}

out[i] = n;

n = 0;

cout << "Case " << i+1 << ": " << out[i] << endl;

}

}

}

 

int pow(int a)

{

a = a * a;

return a;

}

 

 
ZeroJudge Forum