头像

徐景东




离线:18小时前


最近来访(3)
用户头像
无产阶级万岁
用户头像
PlayWithCPP
用户头像
lasd


include [HTML_REMOVED]

using namespace std;

bool is_prome(int n)
{
if(n<2) return false;
for(int i=2;i<=n/i;i++)
if(n%i==0) return false;
return true;
}

int main()
{
int n;
cin>>n;

while(n--)
{
    int x;
    cin>>x;
    if(is_prome(x)) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

}




include [HTML_REMOVED]

using namespace std;

bool is_prome(int n)
{
if(n<2) return false;
for(int i=2;i<=n/i;i++)
if(n%i==0) return false;
return true;
}

int main()
{
int n;
cin>>n;

while(n--)
{
    int x;
    cin>>x;
    if(is_prome(x)) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

}




include [HTML_REMOVED]

int main()
{
int t,n;
scanf(“%d”,&t);
while(t–)
{
scanf(“%d”,&n);
if(n%2==0)
{
n=n/2;
while(n–) printf(“1”);
printf(“\n”);
}
else
{
n=n/2;
printf(“7”);
while(–n) printf(“1”);
printf(“\n”);
}
}
}




include [HTML_REMOVED]

int main()
{
int t;
long long x,y,a,b,c,d;
scanf(“%d”,&t);
while(t–)
{
scanf(“%lld %lld %lld %lld”,&x,&y,&a,&b);
c=y-x;
d=a+b;
if(c%d==0) printf(“%lld\n”,c/d);
else printf(“-1\n”);
}
}




徐景东
20天前

include [HTML_REMOVED]

int main()
{
int t,n;
scanf(“%d”,&t);
while(t–)
{
scanf(“%d”,&n);
if(n%2==0)
{
n=n/2;
while(n–) printf(“1”);
printf(“\n”);
}
else
{
printf(“7”);
n=n/2;
while(–n) printf(“1”);
printf(“\n”);
}
}
}




徐景东
2个月前

include [HTML_REMOVED]

int main()
{
int a,b,c;
scanf(“%d %d %d”,&a,&b,&c);
if(a<=b&&a<=c) printf(“Yes”);
else printf(“No”);
return 0;
}



活动打卡代码 AcWing 786. 第k个数

徐景东
8个月前
#include <iostream>

using namespace std;

const int N = 1000010;

int q[N];

int quick_sort(int q[], int l, int r, int k)
{
    if (l >= r) return q[l];

    int i = l - 1, j = r + 1, x = q[l + r >> 1];
    while (i < j)
    {
        do i ++ ; while (q[i] < x);
        do j -- ; while (q[j] > x);
        if (i < j) swap(q[i], q[j]);
    }

    if (j - l + 1 >= k) return quick_sort(q, l, j, k);
    else return quick_sort(q, j + 1, r, k - (j - l + 1));
}

int main()
{
    int n, k;
    scanf("%d%d", &n, &k);

    for (int i = 0; i < n; i ++ ) scanf("%d", &q[i]);

    cout << quick_sort(q, 0, n - 1, k) << endl;



活动打卡代码 AcWing 785. 快速排序

徐景东
12个月前

include [HTML_REMOVED]

using namespace std;

const int N = 100010;

int q[N];

void quick_sort(int q[], int l, int r)
{
if (l >= r) return;

int i = l - 1, j = r + 1, x = q[l + r >> 1];
while (i < j)
{
    do i ++ ; while (q[i] < x);
    do j -- ; while (q[j] > x);
    if (i < j) swap(q[i], q[j]);
}

quick_sort(q, l, j);
quick_sort(q, j + 1, r);

}

int main()
{
int n;
scanf(“%d”, &n);

for (int i = 0; i < n; i ++ ) scanf("%d", &q[i]);

quick_sort(q, 0, n - 1);

for (int i = 0; i < n; i ++ ) printf("%d ", q[i]);

return 0;

}



活动打卡代码 AcWing 785. 快速排序

徐景东
12个月前

include [HTML_REMOVED]

using namespace std;

const int N = 100010;

int q[N];

void quick_sort(int q[], int l, int r)
{
if (l >= r) return;

int i = l - 1, j = r + 1, x = q[l + r >> 1];
while (i < j)
{
    do i ++ ; while (q[i] < x);
    do j -- ; while (q[j] > x);
    if (i < j) swap(q[i], q[j]);
}

quick_sort(q, l, j);
quick_sort(q, j + 1, r);

}

int main()
{
int n;
scanf(“%d”, &n);

for (int i = 0; i < n; i ++ ) scanf("%d", &q[i]);

quick_sort(q, 0, n - 1);

for (int i = 0; i < n; i ++ ) printf("%d ", q[i]);

return 0;

}