Hãy nhập câu hỏi của bạn vào đây, nếu là tài khoản VIP, bạn sẽ được ưu tiên trả lời.

cần 40 viên kẹo để phăt đủ cho cả lớp

uses crt;
var t,a,i:integer;
begin
clrscr;
t:=1;
a:=1;
for i:=1 to 39 do
begin
a:=a+2;
t:=t+a;
end;
writeln(t);
readln;
end.

b)
uses crt;
var s,i,a:longint;
begin
clrscr;
s:=0;
a:=1;
for i:=1 to 35 do
begin
s:=s+a;
a:=a+3;
end;
writeln('So vien keo la: ',s);
readln;
end.

Mình sẽ nêu ý tưởng và bạn hoàn chỉnh thành chương trình nhé
Câu 1 và câu 2 là cách số từ n đến m phải không bạn ?
1.
s:=0;
for i:=m to n do
if i mod 3=0 then s:=s+i;
2.
s:=0;
for i:=m to n do
if (i mod 3=0) and (i mod 5=0) then s:=s+i;
3.
s:=0;
for i:=1 to m do
s:= s+i*i;
4. Ý tưởng ta có :
12 tháng = 0,15%*12=1,8%
=> Tiền lãi nhận được 100*1.8/100=1.8 đồng
5. Ý tưởng ta có dãy : S=1+4+7+...+n (n là số tiền cần tìm);
Số số hạng là 20.
SSH= (n-1)/3+1=20
=> n=...
6. Ý tưởng ta có dãy : S=1+2+22+24+25+...+n (n là số cần tìm)
Bài này tương tự bài 5 tính tổng
7. Ý tưởng ta có :
a là gà
b là chó
if (a+b=36) and (a*2+b*4=100) then write(....

Program hotrotinhoc;
const fi='score.inp';
fo='score.out';
var f: text;
i,d,t,n,j: integer;
a: array[1..1000] of char;
procedure ip;
begin
assign(f,fi);
reset(f);
n:=1;
while not(eof(f)) do
begin
read(f,a[n]);
inc(n);
end;
close(f);
end;
procedure out;
begin
assign(f,fo);
rewrite(f);
for i:=1 to n do
if a[i]='C' then
begin
d:=d+1;
t:=t+d;
end else if a[i]='N' then d:=0;
write(f,t);
close(f);
end;
begin
ip;
out;
end.
Program hotrotinhoc;
const fi='score.inp';
fo='score.out';
var f: text;
i,d,t,n,j: integer;
a: array[1..1000] of char;
procedure ip;
begin
assign(f,fi);
reset(f);
n:=1;
while not(eof(f)) do
begin
read(f,a[n]);
inc(n);
end;
close(f);
end;
procedure out;
begin
assign(f,fo);
rewrite(f);
for i:=1 to n do
if a[i]='C' then
begin
d:=d+1;
t:=t+d;
end else if a[i]='N' then d:=0;
write(f,t);
close(f);
end;
begin
ip;
out;
end.

#include<bits/stdc++.h>
using namespace std;
int main() {
int T, n;
cin>>T;
for(int t=0;t<T;t++){
int n,k,a,i;
cin>>n>>k;
int a[n];
for(int i=0;i<n;i++){
cin>>a[i];
}
int ans=0;
int c=0;
int sum=0;
int c0=0;
int c1=0;
int c2=0;
for(int i=0;i<n;i++){
sum+=a[i];
}
for(int i=0;i<n;i++){
if(sum<k && i!=0){
sum+=a[i]-1;
}
}
for(int i=0;i<n-1;i++){
for(int j=i+1;j<n;j++){
int sum=0;
for(int l=i;l<j;l++){
sum+=a[l];
}
if(sum==k){
c0=i;
c1=j;
}
}
}
printf("Case %d : %d - %d (c0,c1)\n",t+1,c*n+c0,c*n+c1);
++c;
}
return 0;
}