結果

問題 No.888 約数の総和
ユーザー vjudge1
提出日時 2024-09-26 00:10:44
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 12 ms / 2,000 ms
コード長 494 bytes
コンパイル時間 1,697 ms
コンパイル使用メモリ 190,916 KB
最終ジャッジ日時 2025-02-24 12:40:51
ジャッジサーバーID
(参考情報)
judge5 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘void input()’:
main.cpp:8:24: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    8 |                 freopen(taskname ".inp", "r", stdin);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:9:24: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    9 |                 freopen(taskname ".out","w",stdout);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <bits/stdc++.h>
#define ll long long
using namespace std;

void input(){
	#define taskname ""
	if(fopen(taskname ".inp", "r")){
		freopen(taskname ".inp", "r", stdin);
		freopen(taskname ".out","w",stdout);
	}
}
const int N = 1e6;
ll tonguoc(ll n){
	ll sum =0;
	for(ll i =1; i*i <=n;++i){
		if( n % i == 0){
			sum += i;
			if(i != n/i) sum += n/i;
		}
	}
	return sum;
}
ll n;
int main(){
	input();
	cin.tie(0)->sync_with_stdio(0);
	cin >> n;
	cout << tonguoc(n) << endl;
	return 0;
}
0