Tên đăng nhập Điểm ▾ Bài tập Giới thiệu
19801 201 1
19801 201 1
19801 201 1
19801 201 1
19801 201 1
19801 201 1

include <bits/stdc++.h>

using namespace std;

define ll long long

define endl "\n"

int main(){
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int n, x; cin >> n >> x;
int a[n];
for(int i=0; i<n; i++) cin >> a[i];
int i, j; i = 0;
j = n-1;
int check = 0;
while(i < j){
if(a[i] + a[j] == x){
cout << i+1 << " " << j+1;
check = 1;
break;
}
else if(a[i] + a[j] > x){
j--;
}
else if(a[i] + a[j] < x){
i++;
}
}
if(check == 0) cout << "No solution";
}

19801 201 1
19801 201 1
19801 201 1
19801 201 1
19801 201 1

tap code de sau nay di thi

19801 201 1
19801 201 1
19801 201 1
19801 201 1
19801 201 1
19801 201 1
19801 201 1
19801 201 1
19801 201 1
19801 201 1
19801 201 1
19801 201 1
19801 201 1
19801 201 1
19801 201 1
19801 201 1
19801 201 1
19801 201 1

ok

19801 201 1
19801 201 1
19801 201 1

no

19801 201 1
19801 201 1
19801 201 1
19801 201 1
19801 201 1
19801 201 1
19801 201 1
19801 201 1
19801 201 1
19801 201 1
19801 201 1
19801 201 1
19801 201 1

have a great sense of humor

19801 201 1
19801 201 1
19801 201 1
19801 201 1
19801 201 1
19801 201 1
19801 201 1
19801 201 1
19801 201 1
19801 201 1
19801 201 1
19801 201 1
19801 201 1
19801 201 1
19801 201 1
19801 201 1
19801 201 1
19801 201 1
19801 201 1
19801 201 1
19801 201 1
19801 201 1
19801 201 1
19801 201 1
19801 201 1
19801 201 1
19801 201 1
19801 201 1
19801 201 1
19801 201 1
19801 201 1

include <iostream>

using namespace std;

int main()
{
long long x,n;
cin >> n >> x;
long long a[n];
for (int i=0;i<n;i++) { cin >> a[i];
}
long long l=0,r=n-1;
while (l<r) { if (a[l]+a[r]==x) { break; } else if (a[l]+a[r]>x)
{
r--;
}
else
{
l++;
}
}
if (l<r)
{
cout << l+1 << " " << r+1;
}
else
{
cout << "No solution";
}
return 0;
}

19801 201 1
19801 201 1
19801 201 1
19801 201 1
19801 201 1
19801 201 1
19801 201 1
19801 201 1
19801 201 1
19801 201 1
19801 201 1
19801 201 1
19801 201 1
19801 201 1
19801 201 1
19801 201 1
19801 201 1
19801 201 1

include<stdio.h>

// i == 2 || i == 4 ||
int x[100];
int a[1000];
int d = 0;

void check(int n){
int i;
int num = 0;
int d0 = 0;
int d1 = 0;
for( i = 1; i <= n; i++){
if( x[i] == 0 ){
d0++;
num = num10+4;
}
if( x[i] == 1 ){
d1++;
num = num
10+7;
}
}
if( d0 == d1 ){
d++;
a[d] = num;
}
}
void Try(int i,int n){
int j;
for( j = 0; j <= 1; j++ ){
x[i] = j;
if( i == n ) check(n);
if(i < 8 )Try(i+1,n);
}
}

int main(){
int i;
int n;
Try(1,2);
Try(1,4);
Try(1,6);
Try(1,8);
//for( i = 1; i <= d; i++) printf("%d\n", a[i]);
scanf("%d",&n);
if( n > a[d]) printf("4444477777");
else{
int r = d;
int l = 1;
int mid = (int)(l+r)/2;
while( l != r ){
int mid = (int)(l+r)/2;
if( n > a[mid] ){
if( n <= a[mid+1] ){
printf("%d", a[mid+1]);
break;
}
else l = mid;
}
else{
if( n > a[mid-1] ){
printf("%d", a[mid]);
break;
}
else r = mid;
}
}
}
return 0;
}

19801 201 1
19801 201 1
19801 201 1
19801 201 1
19801 201 1
19801 201 1