baekjoon 20260107
This commit is contained in:
parent
6ee6a07bcc
commit
fe7403f17c
33
code_study/Baekjoon/c/13172.c
Normal file
33
code_study/Baekjoon/c/13172.c
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#define MOD 1000000007
|
||||||
|
|
||||||
|
long long power(long long a, int n);
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
int M;
|
||||||
|
scanf("%d",&M);
|
||||||
|
|
||||||
|
long long ans = 0;
|
||||||
|
while(M--) {
|
||||||
|
long long N, S;
|
||||||
|
scanf("%lld %lld",&N, &S);
|
||||||
|
ans += (S*power(N, MOD-2))%MOD;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("%lld\n", ans%MOD);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
long long power(long long a, int n) {
|
||||||
|
if(n==0) return 1;
|
||||||
|
if(n==1) return a%MOD;
|
||||||
|
|
||||||
|
long long temp = power(a, n/2);
|
||||||
|
long long result = temp*temp%MOD;
|
||||||
|
|
||||||
|
if(n%2) result = result*a%MOD;
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
8
code_study/Baekjoon/c/24883.c
Normal file
8
code_study/Baekjoon/c/24883.c
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
char n;
|
||||||
|
scanf("%c",&n);
|
||||||
|
printf("Naver %s\n", n=='N' || n=='n' ? "D2" : "Whale");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
35
code_study/Baekjoon/python/1865.py
Normal file
35
code_study/Baekjoon/python/1865.py
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
import sys
|
||||||
|
|
||||||
|
input = sys.stdin.readline
|
||||||
|
|
||||||
|
def bellman_ford(edges, N) :
|
||||||
|
dist = [0]*(N+1)
|
||||||
|
|
||||||
|
for n in range(N) :
|
||||||
|
for s,e,t in edges :
|
||||||
|
if dist[e] > dist[s] + t :
|
||||||
|
dist[e] = dist[s] + t
|
||||||
|
|
||||||
|
if n == N-1:
|
||||||
|
return True
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
|
ans = []
|
||||||
|
|
||||||
|
for _ in range(int(input())) :
|
||||||
|
N, M, W = map(int, input().split())
|
||||||
|
edges = []
|
||||||
|
|
||||||
|
for _ in range(M) :
|
||||||
|
S, E, T = map(int, input().split())
|
||||||
|
edges.append((S,E,T))
|
||||||
|
edges.append((E,S,T))
|
||||||
|
|
||||||
|
for _ in range(W) :
|
||||||
|
S, E, T = map(int, input().split())
|
||||||
|
edges.append((S,E,-T))
|
||||||
|
|
||||||
|
ans.append("YES" if bellman_ford(edges, N) else "NO")
|
||||||
|
|
||||||
|
print("\n".join(ans))
|
||||||
Loading…
x
Reference in New Issue
Block a user