当前位置:网站首页>Arc135 a (time complexity analysis)
Arc135 a (time complexity analysis)
2022-07-04 05:35:00 【Find a derivative first】
subject
The question : take x decomposition , Make the product of all numbers after decomposition reach the maximum . about x, It can be broken down into x/2( Round up ) and x/2( Round down )
Ideas : Memory search . When x<=4, Don't divide . otherwise , Keep dividing .
Time complexity : O(logX) or O(logX * loglogX)
use unordered_map
hypothesis n = 2 ^ k,T(n) = T(n/2)+1.T(n) = k = logn
hypothesis n != 2^k, 2^k-1 <= n < 2^k, It can be proved that at most 2k Time f(x),T(n) < 2 * (log(x)+1) = O(log(x)).
If the map
It takes time to memorize logn Time for ,n At most 2(log(x)+1).logn As mentioned above loglogX Time .
Code :
// Problem: A - Floor, Ceil - Decomposition
// Contest: AtCoder - AtCoder Regular Contest 135
// URL: https://atcoder.jp/contests/arc135/tasks/arc135_a
// Memory Limit: 1024 MB
// Time Limit: 2000 ms
//
// Powered by CP Editor (https://cpeditor.org)
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<complex>
#include<cstring>
#include<cmath>
#include<vector>
#include<map>
#include<unordered_map>
#include<list>
#include<set>
#include<queue>
#include<stack>
#define OldTomato ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define fir(i,a,b) for(int i=a;i<=b;++i)
#define mem(a,x) memset(a,x,sizeof(a))
#define p_ priority_queue
// round() rounding ceil() Rounding up floor() Rounding down
// lower_bound(a.begin(),a.end(),tmp,greater<ll>()) First less than or equal to
// #define int long long //QAQ
using namespace std;
typedef complex<double> CP;
typedef pair<int,int> PII;
typedef long long ll;
// typedef __int128 it;
const double pi = acos(-1.0);
const int INF = 0x3f3f3f3f;
const ll inf = 1e18;
const int N = 2e5+10;
const int M = 1e6+10;
const int mod = 998244353;
const double eps = 1e-6;
inline int lowbit(int x){
return x&(-x);}
template<typename T>void write(T x)
{
if(x<0)
{
putchar('-');
x=-x;
}
if(x>9)
{
write(x/10);
}
putchar(x%10+'0');
}
template<typename T> void read(T &x)
{
x = 0;char ch = getchar();ll f = 1;
while(!isdigit(ch)){
if(ch == '-')f*=-1;ch=getchar();}
while(isdigit(ch)){
x = x*10+ch-48;ch=getchar();}x*=f;
}
#define int long long
int n,m,k,T;
map<int,int> mp;
int fun(int x)
{
if(x<=4)
{
return x;
}
if(mp[x]) return mp[x];
if(x&1) return mp[x] = fun(x/2) * fun((x+1)/2) % mod;
else return mp[x] = fun(x/2) * fun(x/2) % mod;
}
void solve()
{
read(n);
write(fun(n)); puts("");
}
signed main(void)
{
T = 1;
// OldTomato; cin>>T;
// read(T);
while(T--)
{
solve();
}
return 0;
}
边栏推荐
- Etcd database source code analysis - initialization overview
- Signification des lettres du module optique et abréviation des paramètres Daquan
- 远程桌面客户端 RDP
- [interested reading] advantageous filtering modeling on long term user behavior sequences for click through rate pre
- Write a complete answer applet (including single choice questions, judgment questions and multiple topics) (III) single choice questions, judgment questions, and the first question display
- Descriptive analysis of data distribution characteristics (data exploration)
- Electronic components mall and data manual download website summary
- VB.net 调用FFmpeg简单处理视频(类库——6)
- RSA加密应用常见缺陷的原理与实践
- Character types of C language
猜你喜欢

transformer坑了多少算力

2022年T电梯修理操作证考试题库及模拟考试

Void convolution, deformable convolution, deformable ROI pooling

Supplement the JS of a video website to decrypt the video

Zhanrui tankbang | jointly build, cooperate and win-win zhanrui core ecology

空洞卷积、可变形卷积、可变形ROI Pooling

光模块字母含义及参数简称大全
![How to use postman to realize simple interface Association [add, delete, modify and query]](/img/e9/bf89eacdebcf2ec84c8a08c28b9ca8.png)
How to use postman to realize simple interface Association [add, delete, modify and query]

Topological sorting and graphical display of critical path

Introduction To AMBA 简单理解
随机推荐
Enterprise level log analysis system elk (if things backfire, there must be other arrangements)
Viewing and using binary log of MySQL
transformer坑了多少算力
2022危险化学品经营单位安全管理人员上岗证题库及答案
VB.net GIF(制作、拆解——优化代码,类库——5)
[matlab] general function of communication signal modulation Fourier transform
Simulink与Arduino串口通信
Graduation design of small programs -- small programs of food and recipes
Thinkphp6.0 middleware with limited access frequency think throttle
FreeRTOS 中 RISC-V-Qemu-virt_GCC 的 锁机制 分析
谷歌 Chrome 浏览器将支持选取文字翻译功能
2022年T电梯修理操作证考试题库及模拟考试
Notepad++ -- display related configurations
1480. 一维数组的动态和
fastjson
[untitled]
[wechat applet] template and configuration (wxml, wxss, global and page configuration, network data request)
[matlab] matlab simulates digital baseband transmission system - digital baseband transmission system
[technology development -25]: integration technology of radio and television network, Internet, telecommunication network and power grid
[matlab] matlab simulates digital bandpass transmission system ask, PSK, FSK system