| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 72292 | team (#118) | 디스토브 (FXCUP3_dstorv) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define M 1000000007
using namespace std;
typedef long long ll;
ll n,r,h,A,b;
string s;
int a[5010];
vector<int> v;
ll pw(ll x,ll y){
ll tmp=1;
while(y){
if(y%2) tmp=tmp*x%M;
y /= 2;
x=x*x%M;
}
return tmp;
}
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);
cin>>n>>r>>h;cin>>s;cin>>A>>b;
ll tmp=gcd(r,h); r/=tmp; h/= tmp;
int tot=0;
for(int i=0;i<n;i++){
if(s[i]=='R') a[i]=1;
else a[i]=2,tot++;
}
for(int i=0;i<n;i++) v.push_back(a[i]);
int cnt=0;
for(int i=0;i<n;i++){
for(int j=0;j<v.size()-1;j++) if(a[j]==1 && a[j+1]==2){
a[j]=0; a[j+1]=1; cnt++;
}
for(int j=v.size();j<n;j++) a[j]=0;v.clear();
for(int j=0;j<n;j++) if(a[j]) v.push_back(a[j]);
for(int j=0;j<v.size();j++) a[j]=v[j];
}
if(cnt>=tot) cout<<pw(pw(r+h,cnt),M-2)*pw(h,cnt)%M<<'\n';;
else cout<<"0"<<'\n';
return 0;
}
