QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#685531#9531. Weird Ceilingy212RE 0ms0kbC++141.5kb2024-10-28 19:58:172024-10-28 19:58:18

Judging History

你现在查看的是最新测评结果

  • [2024-10-28 19:58:18]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-10-28 19:58:17]
  • 提交

answer

#include <bits/stdc++.h>
#define low(x) ((x) & (-(x) ) )
#define E(x) ((x) * (x))
#define ma make_pair
#define rep(a,b,c) for(int a=b;a<=c;a++)
#define per(a,b,c) for(int a=b;a>=c;a--)
#define inf 0x3f3f3f3f
using namespace std;
typedef long long LL;

char ch1;
template<class T>
inline void rd(T& x) {
	x = 0; bool w = 0;
	ch1 = getchar();
	while (!isdigit(ch1)) { ch1 == '-' && (w = 1), ch1 = getchar(); }
	while (isdigit(ch1)) { x = (x << 1) + (x << 3) + (ch1 & 15), ch1 = getchar(); }
	w && (x = (~x) + 1);
}
template<class T>
inline void wr(T x)
{
	if (x < 0) x = -x, putchar('-');
	if (x < 10) {
		putchar(x + 48);
		return;
	}
	T L = x / 10;
	wr(L);
	putchar(x - ((L << 1) + (L << 3)) + 48);
}
/*int head[N],tot;
struct edge{
	int to,nxt;
}e[M];

void add(int u,int v){
	e[++tot].to = v;
	e[tot].nxt = head[u];
	head[u] = tot;
}*/

bool cp(int a,int b){return a > b;} // 大到小

int gcd(int a,int b){
	if(b == 0)return a;
	return gcd(b,a % b);
}

int T , n ;
vector<int > a , b  ;  

int main(){
	cin >> T ; 
	while(T -- ) {
		rd(n) ; 
		LL ans = 1; 
		
		a.clear() ;
		b.clear() ;  
		int m = sqrt(n) ; 
		
		rep(i,1,m) {
			if(n % i == 0) {
				
				a.push_back(i) ;  
				if(i * i == n) continue ; 
				b.push_back(n / i ) ; 
			}
		}
		
		int t = b.size() ; 
		per(i , t - 1, 0 )a.push_back(b[i]) ; 
		
		m = a.size() ; 
		rep(i , 0 , m - 2) {
			ans += n / i * (a[i + 1] - a[i]) ; 
		}
		
		printf("%lld\n" , ans ) ;  
		
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Runtime Error

input:

3
5
451
114514

output:


result: