結果
問題 | No.864 四方演算 |
ユーザー |
|
提出日時 | 2019-12-31 16:00:17 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 12 ms / 1,000 ms |
コード長 | 509 bytes |
コンパイル時間 | 231 ms |
コンパイル使用メモリ | 22,912 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-19 02:59:01 |
合計ジャッジ時間 | 1,514 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:14:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 14 | scanf("%lld%lld", &n, &k); | ~~~~~^~~~~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h>typedef long long int ll;ll val(ll n, ll x) {n++;if (x > (n << 1)) return 0;else if (x > n) x = (n << 1) - x;return x - 1;}int main() {ll n, k, ans = 0;scanf("%lld%lld", &n, &k);for (ll i = 1; i * i <= k; i++) {if (k % i == 0) {if (i * i == k) {ans <<= 1;ans += val(n, i) * val(n, i);printf("%lld\n", ans);return 0;}else ans += val(n, i) * val(n, k / i);}}ans <<= 1;printf("%lld\n", ans);}