結果
問題 | No.2189 六平方和 |
ユーザー |
|
提出日時 | 2023-03-16 00:58:54 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 1 ms / 2,000 ms |
コード長 | 1,200 bytes |
コンパイル時間 | 781 ms |
コンパイル使用メモリ | 99,496 KB |
最終ジャッジ日時 | 2025-02-11 11:43:13 |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 28 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:52:32: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘LL’ {aka ‘long long int’} [-Wformat=] 52 | if (k==5) printf("%d\n", vv); | ~^ ~~ | | | | int LL {aka long long int} | %lld main.cpp:53:27: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘LL’ {aka ‘long long int’} [-Wformat=] 53 | else printf("%d ", vv); | ~^ ~~ | | | | int LL {aka long long int} | %lld main.cpp:36:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 36 | scanf("%lld %d %d", &n, &m, &b); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include<stdio.h>#include<string.h>#include<stdlib.h>#include<math.h>#include <map>#include <vector>#include <queue>#include <deque>#include <set>#include <stack>#include <algorithm>#include <array>#include <unordered_set>#include <unordered_map>#include <string>using namespace std;bool rcmp(int a, int b) { return a>b; }typedef long long LL;int expit(LL b, LL e, int m) {LL r=1;while(e) {if (e&1) { r*=b; r%=m; }b*=b; b%=m;e>>=1;}return r;}int main() {int i, m, b,v , f, k;int ff[8];LL n, vv;scanf("%lld %d %d", &n, &m, &b);v=expit(m, n/2, b);printf("YES\n");if (n&1) {// decompose m to sixfor (k=0; k<6; k++) {ff[k]=0;if (m) {f=sqrt(m);if (f*f>m) f--;ff[k]=f;m-=f*f;}}for (k=0; k<6; k++) {vv=v; vv*=ff[k]; vv%=b; if (vv==0) vv=b;if (k==5) printf("%d\n", vv);else printf("%d ", vv);}} else {if (v==0) v=b;printf("%d %d %d %d %d %d\n", v, b, b, b, b, b);}return 0;}