第十六周周四总结

  这几天打了打codeforce,然后复习了下数位dp,树状dp与状态压缩dp,将之前不是很理解的题弄懂了。

  星期一的cf半夜做,刚做完第一道题要敲第二题电脑就没电了,悲剧。。

  CF Round #450 

A. Find Extra One
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

You have n distinct points on a plane, none of them lie on OY axis. Check that there is a point after removal of which the remaining points are located on one side of the OY axis.

Input

The first line contains a single positive integer n (2 ≤ n ≤ 105).

The following n lines contain coordinates of the points. The i-th of these lines contains two single integers xi and yi (|xi|, |yi| ≤ 109, xi ≠ 0). No two points coincide.

Output

Print "Yes" if there is such a point, "No" — otherwise.

You can print every letter in any case (upper or lower).

Examples
Input
3
1 1
-1 -1
2 -1
Output
Yes
Input
4
1 1
2 2
-1 1
-2 2
Output
No
Input
3
1 2
2 1
4 60
Output
Yes
Note

In the first example the second point can be removed.

In the second example there is no suitable for the condition point.

In the third example any point can be removed.

水题,判断能不能去掉一个点,是否能让所有的点在Y轴的一侧。

#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
int n;
long long x,y;
long long a,b;
while(cin>>n)
    {
    a=0;
    b=0;
    while(n--)
        {
        scanf("%I64d%I64d",&x,&y);
        if(x>0)
            a++;
        else
            b++;
        }
    if(a==1||b==1||a==0||b==0)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    }
return 0;
}

C. Remove Extra One
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

You are given a permutation p of length n. Remove one element from permutation to make the number of records the maximum possible.

We remind that in a sequence of numbers a1, a2, ..., ak the element ai is a record if for every integer j (1 ≤ j < i) the following holds: aj < ai.

Input

The first line contains the only integer n (1 ≤ n ≤ 105) — the length of the permutation.

The second line contains n integers p1, p2, ..., pn (1 ≤ pi ≤ n) — the permutation. All the integers are distinct.

Output

Print the only integer — the element that should be removed to make the number of records the maximum possible. If there are multiple such elements, print the smallest one.

Examples
Input
1
1
Output
1
Input
5
5 1 2 3 4
Output
5
Note

In the first example the only element can be removed.


这题卡在15组样例超时。。。改了好几种方法还是超时。。。

//本题还未通过,待改正后再修改
#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;
int a[100005][2];
int num[100005];
int dp[100005];
int main()
{
int n;
while(cin>>n)
    {
    num[0]=0;
    a[0][0]=0;
    a[0][1]=0;
    memset(dp,0,sizeof(dp));
    for(int i=1;i<=n;i++)
        {
        scanf("%d",&num[i]);
        if(num[i]>=num[a[i-1][0]])
            {
            a[i][0]=i;
            a[i][1]=a[i-1][0];
            }
        else if(num[i]>=num[a[i-1][1]])
                {
                a[i][0]=a[i-1][0];
                a[i][1]=i;
                }
        else
            {
            a[i][0]=a[i-1][0];
            a[i][1]=a[i-1][1];
            }
        if(num[i]>num[a[i-1][0]])
            dp[i]=dp[i-1]+1;
        else
            dp[i]=dp[i-1];
        }
    int s=0;
    int p=1;
    int maxx=0;
    for(int i=n;i>0;i--)
        {
        s=0;
        for(int j=n;j>i;j--)
            {
            if(i==a[j-1][0])
                {
                if(num[j]>num[a[j-1][1]])
                    {
                    s++;
                    //cout<<"1当前j为:"<<j<<" 数值为:"<<num[j]<<" 之前最大值为:"<<num[a[j-1][1]]<<" s="<<s<<endl;
                    }
                }
            else
                {
                if(num[j]>num[a[j-1][0]])
                    {
                    s++;
                   // cout<<"2当前j为:"<<j<<" 数值为:"<<num[j]<<" 之前最大值为:"<<num[a[j-1][1]]<<" s="<<s<<endl;
                    }
                }
            }
        int sum=dp[i-1];
        if(s+sum==maxx)
            {
            if(num[i]<num[p])
                p=i;
            }
        else if(s+sum>maxx)
                {
                maxx=s+sum;
                p=i;
                }
       // cout<<s+sum<<" ";
        /*if(i==1)
            cout<<s+sum<<endl;
        if(i==16)
            cout<<s+sum<<endl;*/
        }
   // cout<<endl;
   /* for(int i=1;i<=n;i++)
        cout<<dp[i]<<" ";
    cout<<endl<<endl;*/
    cout<<num[p]<<endl;
   // cout<<maxx<<endl;
    }
return 0;
}
B. Position in Fraction
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

You have a fraction . You need to find the first occurrence of digit c into decimal notation of the fraction after decimal point.

Input

The first contains three single positive integers a, b, c (1 ≤ a < b ≤ 105, 0 ≤ c ≤ 9).

Output

Print position of the first occurrence of digit c into the fraction. Positions are numbered from 1 after decimal point. It there is no such position, print -1.

Examples
Input
1 2 0
Output
2
Input
2 3 7
Output
-1

这道题我还想了半天怎么做,结果暴力就可以。。。
#include<iostream>
using namespace std;
int main()
{
int a,b,c,s;
while(cin>>a>>b>>c)
    {
    s=-1;
    for(int i=1;i<100000;i++)
        {
        a*=10;
        if(a/b==c)
            {
            s=i;
            break;
            }
        a%=b;
        }
    cout<<s<<endl;
    }
return 0;
}




要实现每年12月的第一个六凌晨2点的任务调度,可以通过分析 Cron 表达式的各个字段及其含义来构建合适的表达式。 Cron 表达式通常由六个或七个字段组成(视具体实现而定),分别为秒、分、小时、日期、月份、星期以及可选的年份。对于本需求: - **秒**:设为 `0`,因为任务在整点触发。 - **分**:设为 `0`,同样是因为任务在整点触发。 - **小时**:设为 `2`,表示凌晨两点。 - **日期**:由于我们关注的是具体的某一天(即 12 月的第一个六),因此该字段应留为空白或使用特殊字符 `?` 来忽略具体日期[^4]。 - **月份**:设为 `12`,代表十二月。 - **星期**:设为 `6` 或者 `SAT`,表示六;同时为了限定其为当月的第一,需附加特殊的标记 `#1`,这表明这是每个月中的第一个六[^3][^4]。 - **年份**(如果支持):可以省略,因为我们希望此规则适用于每一年。 综合以上各部分,最终得到如下 Cron 表达式: ```cron 0 0 2 ? 12 SAT#1 * ``` 以下是对此表达式的解释: - `0`: 秒数,在第零秒启动; - `0`: 分钟数,在零分钟处运行; - `2`: 小时数,指明于凌晨两时操作; - `?`: 不指定确切的日数值,因已通过星期设定条件; - `12`: 指定仅限于十二月份生效; - `SAT#1`: 定义了只针对每月首度出现之六工作; - `*`: 对年度无特别限制,默认全年皆适用[^5]。 ### 注意事项 某些系统的 Cron 实现可能并不完全支持上述全部特性,特别是关于“哪一”的定义(`#`) 和 是否包含秒级别控制等方面存在差异,请确认目标环境的支持情况后再应用该配置。 ```python import schedule import time def job(): print("Task executed at the first Saturday of December, 2 AM.") schedule.every().december.do(job).on_first_saturday.at('02:00') while True: schedule.run_pending() time.sleep(1) ``` 注意这里的 Python 调度库仅为示意,并不一定原生支持如此复杂的 Cron 功能,实际部署仍建议依据系统自带工具完成。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值