Dan robocontest javoblari



Yüklə 0,58 Mb.
səhifə1/7
tarix07.01.2024
ölçüsü0,58 Mb.
#204426
  1   2   3   4   5   6   7
2 5411487045807781686

MUHAMMAD AL-XORAZMIY NOMIDAGI TATU FARG’ONA FILIALI KIF FAKULTETI KOMPYUTER INJINERING YO’NALISHI 615_22 GURUH TALABASI Tohirjonov ziyodbek DASTURLASH DAN ROBOCONTEST JAVOBLARI.




1-masala
#include
using namespace std;
int main()
{
long long a,b;
cin>>a>>b;
cout<return 0;
}

2-masala
#include
using namespace std;
int main()
{
float A,B;
cin>>A>>B;
if(A>B)
{
cout<<">";
}
if(A==B)
{
cout<<"=";
}
if(A{
cout<<"<";
}
return 0;
}

3-masala
#include
#include
#include
#include
using namespace std;
char s1[100000000],s2[100000000];
ifstream in("input.txt");
ofstream out("output.txt");
int a[100000000],b[100000000],c[100000000];
int main() {
in>>s1>>s2;
for(int i=0; ia[i]=s1[i]-48;
}
for(int i=0; ib[i]=s2[i]-48;
}
int m=min(strlen(s1), strlen(s2));
int Max=max(strlen(s1), strlen(s2))-1;
for(int i=Max; i>=0; i--) {
if(strlen(s1)>=strlen(s2) ) {
c[i]=c[i]+a[i]+b[m-1];
if(i>0) {
c[i-1]=c[i]/10;
c[i]=c[i]%10;
} m-=1;
}
else
if(strlen(s2)>strlen(s1)) {
c[i]=c[i]+b[i]+a[m-1];
if(i>0) {
c[i-1]=c[i]/10;
c[i]=c[i]%10;
} m-=1;
}
}
for(int i=0; iout<return 0;
}

4-masala
#include
using namespace std;
int main()
{
long long a , b;
cin >> a >> b ;
cout << a*b;
return 0;
}

5-masala
#include
#include
using namespace std;
int main()
{
long long z, n, c=0, res;
cin >> z;
if(z==0) return puts("-1"), 0;
n=z>0 ? z : -z;
for (int i=1; 1LL * i * i<=n; i++)
{
if(n%i==0)
{
c++;
if(i*i!=n)c++;
}
}
if(c%2==1 && z>0) res=c+1;
else{
res =c;
}
cout << res;
return 0;
}
6-masala
#include
using namespace std;
int main()
{
int n,k;
cin>>n;
k=log(n)/log(10)+1;
if(n%400==0||n%4==0&&n%100!=0)
{
if(k==1){cout << "12/09/000"<< n ;}
if(k==2){cout << "12/09/00"<< n ;}
if(k==3){cout << "12/09/0"<< n ;}
if(k==4){cout << "12/09/"<< n ;}
}
else{
if(k==1){cout << "13/09/000"<< n ;}
if(k==2){cout << "13/09/00"<< n ;}
if(k==3){cout << "13/09/0"<< n ;}
if(k==4){cout << "13/09/"<< n ;}
}
return 0;
}

7-masala
#include
using namespace std;
int main()
{
long long n,k;
cin>>n;
long long f[46]={0,1};
for (int i=2; i<=45; i++)
{
f[i]=f[i-2]+f[i-1];
}
cout << f[n]*2;
return 0;
}

8-masala
#include
using namespace std;
int main()
{
long long a,b,c,d,e,mn,mx;
cin>>a>>b>>c>>d>>e;
mn=min(min(a,b),min(c,min(e,d)));
mx=max(max(a,b),max(c,max(e,d)));
cout< return 0;
}


9-masala
#include
using namespace std;
int main(){
int n, m;
cin >> n;
int arr[105];
for (int i = 0; i < n; i++){
cin >> arr[i];
}
for (int i = 0; i < n; i++){
for (int j = 0; j < n - i - 1; j++){
if (arr[j] > arr[j + 1]){
m = arr[j];
arr[j] = arr[j + 1];
arr[j + 1] = m;
}
}
}
for (int i = 0; i < n; i = i + 2){
if (arr[i] != arr[i + 1]){
cout << arr[i];
return 0;
break;
}
}
cout << arr[n - 1];
return 0;
}

10-masala
#include
using namespace std;
int main()
{
long long A,B,C,N,d;
cin >> N;
cin >> A >> B >> C;
d=A+B+C;
if(N<=d)
{
cout << "Yes";
}
else
{
cout << "No";
}
return 0;
}

11-masala
#include
using namespace std;
int main()
{
int n;
cin>>n;
long long a[100];
for (int i=0; i{
cin>>a[i];
}
sort(a,a+n);
cout << a[n-2];
return 0;
}


12-masala
#include
#include
using namespace std;
int main(){
long long int n, soniTub = 1;
cin >> n;
bool ha = true;
for (int j = 3; j <= n; j += 2){
ha = true;
for (int i = 2; i <= sqrt(j); i++)
{
if (j % i == 0)
{
ha = false;
break;
}
}
if (ha)
soniTub++;
}
if (soniTub % 2 != 0)
cout << "Ali";
else
cout << "Bobur";
}
13-masala
#include
using namespace std;
int main(){
long long n, k;
cin>>n>>k;
if(n==0) cout<<"1";
else
cout<}

14-masala
#include
#include
#define qol 1000000007
int binpow(int a,int n){
if(n==0) return 1;
if(n%2==0){
int x=binpow(a,n/2);
return 1LL*x*x%qol;}
return 1LL*a*binpow(a,n-1)%qol;
}
using namespace std;
int main(){
int n,k;
cin>>n>>k;
cout<}

15-masala
#include
using namespace std;
const int mod = 1e9 + 7;
int binpow(int a, int n ){
if(n == 0) return 1;
if(n % 2 == 0){
int x = binpow(a, n/2);
return 1LL * x * x % mod;
}
return 1LL*a*binpow(a, n-1) % mod;
}
int main(){
int n, k, a, b;
cin >> n >> k;
a = binpow(k, n) - 1;
b = k - 1;
cout << 1LL * a * binpow(b, mod - 2) % mod;
return 0;
}


16-masala
#include
using namespace std;

typedef long long ll;

string son(ll n){
string satr;
switch(n){
case 1: return("bir");
case 2: return("ikki");
case 3: return("uch");
case 4: return("to'rt");
case 5: return("besh");
case 6: return("olti");
case 7: return("yetti");
case 8: return("sakkiz");
case 9: return("to'qqiz");
case 10: return("o'n");
case 20: return("yigirma");
case 30: return("o'ttiz");
case 40: return("qirq");
case 50: return("ellik");
case 60: return("oltmish");
case 70: return("yetmish");
case 80: return("sakson");
case 90: return("to'qson");
case 100: return("yuz");
case 1000: return("ming");
case 1000000: return("million");
case 1000000000: return("milliard");
default: return("");
}
}

string maydala(int n){


string satr="";
int i=0;
satr=son(n%10)+satr;
if(n%100/10!=0) {
if(satr!="") satr=" "+satr;
satr=son(n%100/10*10)+satr;}
if(n>=100) {
if(satr!="") satr=" "+satr;
satr=son(n/100)+" yuz"+satr;}
return satr;
}

int main(){


int arr[4];
ll n,i=0;
string satr,maydaSatr;
cin>>n;
while(n!=0){
arr[i]=n%1000;
n/=1000;
i++;
}
string javob[i];
for(int j=0;j//Maydalangan satr
maydaSatr="";
maydaSatr=maydala(arr[j]);
if(j!=0 && j!=3 && arr[j]!=0) maydaSatr+=" "+son(pow(10,j*3))+" ";
if(j==3) maydaSatr+=" "+son(pow(10,3*3))+" ";
satr=maydaSatr+satr;
}
cout<}
17-masala
x#include
using namespace std;
int fff(int n)
{
int s=0, p;
while (n>0)
{
p=n%10;
s=s+p;
n=n/10;
}
return s*s;
}
int main()
{
int n;
cin>>n;
int k=0;
int i=1, h;
while (k{
if(i%fff(i)==0) k++;
h=i; i++;
}
cout<return 0;
}

18-masala
#include
#include
using namespace std;
int main() {
int a[] = {1,2,3,4,5,6,7,8,9};
int b[9];
for(int i = 0; i < 9; i++) cin >> b[i];
int res = 100;
int s = 0;
do{
if (
(a[0] + a[1] + a[2]) == 15 &&
(a[3] + a[4] + a[5]) == 15 &&
(a[6] + a[7] + a[8]) == 15 &&
(a[0] + a[3] + a[6]) == 15 &&
(a[1] + a[4] + a[7]) == 15 &&
(a[2] + a[5] + a[8]) == 15 &&
(a[0] + a[4] + a[8]) == 15 &&
(a[2] + a[4] + a[6]) == 15) {
int s = 0;
for(int i = 0; i < 9; i++)
s += abs(a[i] - b[i]);
if(res > s) res = s;
}
}while(next_permutation(a,a+9));
cout << res << endl;
return 0;
}


19-masala
#include

using namespace std;


int main() {
unsigned int N,K;
cin >> N >> K;
cout << K/N;
return 0;
}

20-masala

#include

using namespace std;
int main() {
unsigned int N,K;
cin >> N >> K;
cout << K%N;
return 0;
}

21-masala
#include
using namespace std;
int main()
{
int a,b,c,d,k,h;
cin>>a>>b>>c;
if(a%2==1)
{
d=a/2+1;
}
else{
d=a/2;
}
if(b%2==1)
{
k=b/2+1;
}
else{
k=b/2;
}
if(c%2==1)
{
h=c/2+1;
}
else{
h=c/2;
}
cout<return 0;
}

22-masala
#include
using namespace std;
int main()
{
long long N,b;
cin >> N ;
b=(N%100)/10;
cout << b;
return 0;
}

23-masala

#include


using namespace std;
int main()
{
long long N,b;
cin >> N ;
b=N%10;
cout << b;
return 0;
}


24-masala
#include

using namespace std;

int main ()
{
long long h,m,s,H,M,S,a,b;
cin>>h>>m>>s>>H>>M>>S;
a=h*3600+m*60+s;
b=H*3600+M*60+S;
cout << b-a;
return 0;
}

25-masala
#include
#include
#include
using namespace std;
int main () {
string n;
cin >>n;
int q=0,k=86400;
for (char c:n)
q=(q*10+(c-48))%k;
int h,m,s;
h=q/3600;
q%=3600;
m=q/60;
s=q%60;
printf("%d:%02d:%02d",h,m,s);
return 0;
}


26-masala
#include
using namespace std;
int main () {
int t;
cin >>t;
long long n,q,mod=1e9+7;
for (int i=0;icin >>n;
q=n%mod;
cout<}
return 0;
}


27-masala
#include

using namespace std;

int main()
{
int n,m;
int t;
cin>>t;
while(t--){
cin>>n>>m;
int b=0, k=n-1;
for(int i=0;i//cout<if(k==m||b==m){
cout<}
if(i%2==0)
k--;
else
b++;
}
}
return 0;
}

28-masala
#include
using namespace std;
int main(){
int n , ax, ay , bx, by;
cin >> n;
for(int i = 0; i < n; i++)
{
cin >> ax >> ay >> bx >> by;
cout << 2 * bx - ax <<' '<< 2 * by - ay << endl;
}
return 0;
}

28-masala
#include
using namespace std;
long long divisorsSame(long long n)
{
long long even_div = 0, odd_div = 0;
for (long long i = 1; i <= sqrt(n); i++) {
if (n % i == 0) {

if (n / i == i) {

if (i % 2 == 0) {
even_div++;
}
else {
odd_div++;
}
}
else {
if (i % 2 == 0) {
even_div++;
}
else {
odd_div++;
}
if (n / i % 2 == 0) {
even_div++;
}
else {
odd_div++;
}
}
}
}

return even_div;


}
int main()
{
long long N,n;
cin >>n;
for(long long i=0;icin >>N;
cout << divisorsSame(N)<}
return 0;
}
29-masala
#include
using namespace std;
long long divisorsSame(long long n)
{
long long even_div = 0, odd_div = 0;
for (long long i = 1; i <= sqrt(n); i++) {
if (n % i == 0) {

if (n / i == i) {

if (i % 2 == 0) {
even_div++;
}
else {
odd_div++;
}
}
else {
if (i % 2 == 0) {
even_div++;
}
else {
odd_div++;
}
if (n / i % 2 == 0) {
even_div++;
}
else {
odd_div++;
}
}
}
}

return even_div;


}
int main()
{
long long N,n;
cin >>n;
for(long long i=0;icin >>N;
cout << divisorsSame(N)<}
return 0;
}


Yüklə 0,58 Mb.

Dostları ilə paylaş:
  1   2   3   4   5   6   7




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©azkurs.org 2024
rəhbərliyinə müraciət

gir | qeydiyyatdan keç
    Ana səhifə


yükləyin