A - Don't be late
python
D, T, S = list(map(int, input().split()))
if T >= D / S:
print('Yes')
else:
print('No')
B - Substring
- 1000*1000なら全探索で間に合う
python
S = str(input())
T = str(input())
Ans=1000
for i in range(0, len(S)):
Tmp=0
if i + len(T) <= len(S):
for j in range(0, len(T)):
if S[i+j] != T[j]:
Tmp += 1
Ans = min(Ans, Tmp)
print(Ans)
C - Sum of product of pairs
- 2^100000 * 2^100000だと全探索では間に合わない
- O(N)にする
- グラフを作ると答えが見ます
C++
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<iomanip>
#include<map>
#include<queue>
#include<cmath>
#include<cstdio>
#define rep(i,n) for(int i=0; i<(n); ++i)
#define pai 3.1415926535897932384
using namespace std;
using ll =long long;
using P = pair<int,int>;
#define MOD 1000000007;
int main(int argc, const char * argv[]) {
int N;
ll A[200000];
ll AA[200000];
cin >> N;
for(int i=0; i<N; i++){
cin >> A[i];
if(i==0) AA[i] = A[i];
else AA[i] = (A[i] + AA[i-1]) % MOD;
}
ll Ans=0;
for(int i=0; i<N; i++){
Ans += (AA[i] * A[i]) % MOD;
Ans = (Ans - A[i] * A[i]) % MOD;
if(Ans < 0) Ans += MOD;
}
cout << Ans << endl;
return 0;
}