1 solutions

  • 0
    @ 2025-11-5 14:56:37

    C :

    #include <stdio.h>
    #include <math.h>
    #define M 10000000 
    int main() {
    	int array[M] = {0};
    	double a, x, s;
    	long n, i, j, t, y;
    	scanf("%ld", &n);
    	for (i = 1; i <= n; i++) {
    		scanf("%lf%ld", &a, &t);
    		x = 0;
    		for (j = 1; j <= t; j++) {
    			x += a;
    			modf(x, &s);
    			y = (double)s;
    			array[y] = !array[y];
    		}
    	}
    	for (j = 1; j < M; j++) {
    		if (array[j]) {
    			break;
    		}
    	}
    	printf("%d\n", j);
    	return 0;
    }
    

    C++ :

    #include<iostream>
    #include<cstdio>
    #include<cstring>
    #include<cmath>
    #include<algorithm>
    using namespace std;
    int n,len=0;
    long long a[2000010];
    void init();
    void work();
    int main()
    {
    	//freopen("light.in","r",stdin);
    	//freopen("light.out","w",stdout);
    	init();		
    	work();
    	return 0;
    }
    void init()
    {
    	memset(a,0,sizeof(a));
    	cin>>n;
    	double s;
    	int t,k;
    	for(int i=1;i<=n;i++)
    	{
    		cin>>s>>t;	
    		for(int j=1;j<=t;j++)
    		{
    			k=floor(s*j);
    			len++;
    			a[len]=k;
    		}
    	}
    }
    void work()
    {
    	sort(a+1,a+len+1);
    	//cout<<len<<endl;	
    	//for(int i=1;i<=len;i++)cout<<a[i]<<' ';
    	int i=1;
    	while(i<=len)
    	{
    		int k=1;
    		while(a[i]==a[i+1]&& i<len)
    		{
    			i++;
    			k++;
    		} 
    		if(k%2!=0)
    		{
    			cout<<a[i]<<endl;
    			break;
    		}
    		i++;
    	}
    }
    
    • 1

    Information

    ID
    16246
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    (None)
    Tags
    # Submissions
    0
    Accepted
    0
    Uploaded By