結果

問題 No.2576 LCM Pattern
ユーザー owo_zzz
提出日時 2025-01-31 03:27:10
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 27 ms / 2,000 ms
コード長 3,693 bytes
コンパイル時間 1,488 ms
コンパイル使用メモリ 151,308 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2025-01-31 03:27:13
合計ジャッジ時間 2,932 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 23
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:128:16: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
  128 |         freopen(task".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
main.cpp:129:16: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
  129 |         freopen(task".out","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
main.cpp:133:16: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
  133 |         freopen(task1".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
main.cpp:134:16: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
  134 |         freopen(task1".out","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #
プレゼンテーションモードにする

// #pragma GCC optimize("Ofast,unroll-loops")
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <locale>
#include <map>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <unordered_set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <utility>
#include <valarray>
#include <vector>
#include <cstring>
#include <unordered_map>
#include <cmath>
#include <array>
#include <cassert>
#include <random>
#include <chrono>
using namespace std;
#define BIT(i,j) (((i)>>(j))&1LL)
#define MASK(i) (1LL<<(i))
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) (int)(x).size()
#define fi first
#define se second
#define ull unsigned long long
#define ll long long
#define ld long double
#define vi vector<int>
#define vvi vector<vi>
#define vvvi vector<vvi>
#define pii pair<int,int>
#define vpii vector<pii>
#define vvpii vector<vpii>
#define endl "\n"
#define MP make_pair
#define int ll
//------------------------------------------------------------------------------------------------//
template<typename T1, typename T2> bool mini(T1 &a, T2 b){if(a>b){a=b;return true;}return false;}
template<typename T1, typename T2> bool maxi(T1 &a, T2 b){if(a<b){a=b;return true;}return false;}
template<typename T> T gcd(T a, T b) { while(b) { a %= b; swap(a,b); } return a; }
template<typename T> T lcm(T a, T b) { return a/gcd(a,b)*b; }
//-----------------------------------------------------------------------------------------------//
const ll LINF = 1e18;
const int INF = 1e9;
const int LOG = 20;
const int MAXN = 5e5+7;
const int N = 1e2+3;
const int MOD = 998244353;
const int BASE = 1e5;
const ld EPS = 1e-9;
const ld PI = acos(-1);
const int OFFSET = 1e3;
//------------------------------------------------------------------------------------------------//
void add(int &a, int b){
a += b;
if(a>=MOD) a -= MOD;
if(a<0) a += MOD;
}
int POW(int a, int b){
int res = 1;
while(b){
if(b&1) res = 1LL*res*a%MOD;
a = 1LL*a*a%MOD;
b /= 2;
}
return res;
}
map<int,int> dp;
int n;
int calc(int x){
if(x==1) return 1;
if(dp.count(x)) return dp[x];
int &res = dp[x],cnt = 0;
res = 0;
// cerr << res << " " << x << " " << n << endl;
for(int i = 1; i*i<=x; i++){
if(x%i==0){
add(res,-calc(i));
if(x/i!=i) cnt += 2; else cnt += 1;
if(i>1 && x/i!=i){
add(res,-calc(x/i));
}
}
}
add(res,POW(cnt,n));
return res;
}
void solve(){
int m; cin >> n >> m;
cout << calc(m);
}
signed main(){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
#define task "test"
if(fopen(task".inp","r")){
freopen(task".inp","r",stdin);
freopen(task".out","w",stdout);
}
#define task1 "nothing"
if(fopen(task1".inp","r")){
freopen(task1".inp","r",stdin);
freopen(task1".out","w",stdout);
}
int test = 1;
while(test--){
solve();
}
cerr << "\nTime elapsed: " << 1000*clock()/CLOCKS_PER_SEC << "ms\n";
return 0;
}
/** /\_/\
* (= ._.)
* / >TL \>AC
**/
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0