結果
問題 | No.2185 平方数の下6桁 |
ユーザー |
|
提出日時 | 2023-01-13 22:12:59 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 15 ms / 2,000 ms |
コード長 | 1,015 bytes |
コンパイル時間 | 3,833 ms |
コンパイル使用メモリ | 254,848 KB |
最終ジャッジ日時 | 2025-02-10 02:39:00 |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 37 |
コンパイルメッセージ
main.cpp:9:12: warning: built-in function ‘pow10’ declared as non-function [-Wbuiltin-declaration-mismatch] 9 | vector<ll> pow10; | ^~~~~
ソースコード
#include<bits/stdc++.h>using namespace std;#include<atcoder/all>using namespace atcoder;using ll = long long;string s;vector<ll> pow2[] = {{0},{1,9},{},{},{2,8},{5},{4,6},{},{},{3,7}};ll n;vector<ll> pow10;bool is = false;void dfs(ll cur,vector<ll> ans,ll depth){if(depth==n){reverse(ans.begin(),ans.end());//for(auto &i:ans)cout<<i;cout<<endl;if(cur%pow10[depth]==0){is = true;}return;}for(auto &i:{0,1,2,3,4,5,6,7,8,9}){ll nx = cur;for(int j = 0;j<ans.size();j++){nx -= pow10[depth+j]*ans[j]*i*2;}nx -= pow10[depth*2]*i*i;//cout<<nx/pow10[depth]<<' '<<i<<endl;ans.push_back(i);if(nx%pow10[depth+1]==0){dfs(nx,ans,depth+1);}ans.pop_back();}}ll INF = 1e18;void solve(){{ll cur = 1;for(int i = 0;i<19;i++){pow10.push_back(cur);cur*=10;}}n = s.size();dfs(stoll(s)+INF,{},0);if(is)cout<<"YES"<<endl;else cout<<"NO"<<endl;}signed main(){cin.tie(nullptr);ios::sync_with_stdio(false);cin >> s;solve();}