20250717 baekjoon
This commit is contained in:
parent
af34d3e2c0
commit
4fcba77861
24
code_study/Baekjoon/c/11659.c
Normal file
24
code_study/Baekjoon/c/11659.c
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
int N, M;
|
||||||
|
scanf("%d %d",&N, &M);
|
||||||
|
int* accSum = (int*)malloc(sizeof(int)*(N+1));
|
||||||
|
accSum[0] = 0;
|
||||||
|
for(int i=1; i<=N; i++){
|
||||||
|
int n;
|
||||||
|
scanf("%d",&n);
|
||||||
|
accSum[i] += accSum[i-1] + n;
|
||||||
|
}
|
||||||
|
|
||||||
|
while(M--){
|
||||||
|
int a, b;
|
||||||
|
scanf("%d %d",&a, &b);
|
||||||
|
printf("%d\n",accSum[b]-accSum[a-1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
free(accSum);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
22
code_study/Baekjoon/java/_9461.java
Normal file
22
code_study/Baekjoon/java/_9461.java
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class _9461 {
|
||||||
|
public static void main(String[] args){
|
||||||
|
Scanner sc = new Scanner(System.in);
|
||||||
|
int T = sc.nextInt();
|
||||||
|
long[] P = new long[101];
|
||||||
|
P[0] = 0;
|
||||||
|
P[1] = 1;
|
||||||
|
P[2] = 1;
|
||||||
|
for(int i=3; i<101; i++){
|
||||||
|
P[i] = P[i-2] + P[i-3];
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int i=0; i<T; i++){
|
||||||
|
int N = sc.nextInt();
|
||||||
|
System.out.println(P[N]);
|
||||||
|
}
|
||||||
|
|
||||||
|
sc.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
4
code_study/Baekjoon/python/11727.py
Normal file
4
code_study/Baekjoon/python/11727.py
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
dp = [0,1,3]
|
||||||
|
for i in range(3,1001):
|
||||||
|
dp.append((2 * dp[i-2] + dp[i-1])%10007)
|
||||||
|
print(dp[int(input())])
|
||||||
9
code_study/Baekjoon/ts/11726.ts
Normal file
9
code_study/Baekjoon/ts/11726.ts
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
export {};
|
||||||
|
const N: number = Number(require("fs").readFileSync(0,"utf8").toString().trim());
|
||||||
|
let dp: number[] = [0,1,2];
|
||||||
|
if(N>2){
|
||||||
|
for(let i=3; i<=N; i++){
|
||||||
|
dp[i] = (dp[i-2] + dp[i-1])%10007;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.log(dp[N]);
|
||||||
Loading…
x
Reference in New Issue
Block a user