You are on page 1of 6

Cau 2.

#include <bits/stdc++.h>

using namespace std;

string n;

int res=0;

main(){

freopen("cau2.inp","r",stdin);

freopen("cau2.out","w",stdout);

ios_base::sync_with_stdio(false);

cin.tie(0);

cout.tie(0);

cin >> n;

for(int a=0;a<n.size();a++){

res+=n[a]-48;

cout << res <<"\n";

reverse(n.begin(),n.end());

cout << n << " ";

Bai 3.

#include <bits/stdc++.h>

using namespace std;

bool check(int n){

if(n<2){

return false;

if(n==2||n==3){

return true;

}
for(int i=2;i<=sqrt(n);i++){

if(n%i==0){

return false;

return true;

const int MAX=1e5+6;

int n,h[MAX],d=0,res=INT_MIN,res1=0,MAXn=0;

map<int,int>cnt;

main(){

freopen("cau3.inp","r",stdin);

freopen("cau3.out","w",stdout);

ios_base::sync_with_stdio(false);

cin.tie(0);

cout.tie(0);

cin >> n;

for(int a=0;a<n;a++){

cin >> h[a];

if(check(h[a])==true){

d++;

if(h[a]<0){

res=max(res,h[a]);

cnt[h[a]]++;

if(cnt[h[a]]>res1){

res1=cnt[h[a]];

MAXn=h[a];
}

if(res==INT_MIN){

res=0;

cout << d << "\n" << res <<"\n"<< MAXn <<" "<<res1;

Cau 4.

#include <bits/stdc++.h>

using namespace std;

string n;

map<int,int>cnt;

main(){

freopen("cau4.inp","r",stdin);

freopen("cau4.out","w",stdout);

ios_base::sync_with_stdio(false);

cin.tie(0);

cout.tie(0);

getline(cin,n);

for(int a=0;a<n.size();a++){

if(n[0]>=97){

n[0]=(char)n[0]-32;

while(n[0]==' '){

n.erase(a,1);

if(n[a]==' '&&n[a+1]==' '){

n.erase(a,1);

a--;
}

cout << n << "\n";

n[0]=(char)n[0]+32;

for(int a=0;a<n.size();a++){

cnt[n[a]]++;

for(int a=97;a<=122;a++){

if(cnt[(char)a]>0){

cout << (char)(a-32) << " " << cnt[(char)a] << "\n";

Cau 5.

#include <bits/stdc++.h>

using namespace std;

#define ll long long

const ll MAX=1e8+7;

int l,r,n;

ll h[MAX],res=0,v[MAX];

main(){

freopen("cau5.inp","r",stdin);

freopen("cau5.out","w",stdout);

ios_base::sync_with_stdio(false);

cin.tie(0);

cout.tie(0);

cin >> n;

v[0]=h[0]=0;
l=1;

for(int a=1;a<=n;a++){

cin >> h[a];

v[a]=v[a-1]+h[a];

if(v[a]>0){

res=v[a];

r=a;

for(int a=1;a<n;a++){

for(int i=a+1;i<=n;i++){

if(v[i]-v[a]>res){

res=v[i]-v[a];

l=a+1;

r=i;

cout << l << "\n" << r << "\n" << res;

Cau 6.

#include <bits/stdc++.h>

using namespace std;

string n;

int k;

int val=0;

main()

freopen("cau6.inp","r",stdin);
freopen("cau6.out","w",stdout);

ios_base::sync_with_stdio(false);

cin.tie(0);

cout.tie(0);

cin >> n >> k;

for(int a=0;a<n.size();a++){

if(val>=k){

val=val%k;

if(n[a]-'0'<k){

val=val*10+n[a]-'0';

cout << val%k;

You might also like