NC252833. Brilliant Idea
描述
输入描述
First line a single integer , representing the length of the string.
输出描述
A single line contains three integers.
The first one represents the number of strings satisfying , module .
The second one represents the number of strings satisfying and is finite, module .
The third one represents the number of strings satisfying is infinite, module .
示例1
输入:
2
输出:
26 650 0
说明:
There are strings with length satisfies , and their .C++(clang++ 11.0.1) 解法, 执行用时: 3ms, 内存消耗: 476K, 提交时间: 2023-07-06 09:20:04
#include <iostream> using namespace std; long long a,b,c=26,sum=1,mod=1e9+7; int main() { cin>>a; if(a==2) cout<<"26 650 0"; else{ b=a%mod; while(b>0){ if(b&1) sum=(sum*c)%mod; c=(c*c)%mod; b>>=1; } cout<<"26 0 "<<(sum-26+mod)%mod; } return 0; }
C++(g++ 7.5.0) 解法, 执行用时: 3ms, 内存消耗: 464K, 提交时间: 2023-06-09 22:38:08
#include <iostream> using namespace std; long a,b,c=26l,sum=1,mod=1e9+7; int main() { cin>>a; if(a==2) cout<<"26 650 0"; else{ b=a%mod; while(b>0){ if(b&1) sum=(sum*c)%mod; c=(c*c)%mod; b>>=1; } cout<<"26 0 "<<(sum-26+mod)%mod; } return 0; }