4 条题解

  • 3
    @ 2022-1-8 20:13:02
    #include <stdio.h>
    int n;
    int main()
    {
        scanf("%d",&n);
        long long ans = n;
        if(ans%2==1)
        {
        	ans = ans+1;
        	ans/=2;
        	ans *= n;
    	}
    	else 
    	{
    		ans /=2;
    		ans *= (n+1); 
    	}
    	for(int i = 0,x;i < n - 1;i++)
    	{
    		scanf("%d",&x);
    		ans -= x;
    	}
    	printf("%lld\n",ans);
    	return 0;
    }
    
    • 0
      @ 2024-4-21 14:52:03
      /*
      int       %d
      longlong  %lld
      float     %f
      double    %lf
      char      %c
      char[]    %s
      'a'=97
      'z'=122
      'A'=65
      'Z'=90
      '0'=48
      '9'=57
      */
      #include <cstdio>
      using namespace std;
      const int N=1e7+10;
      const int INF=0x3f3f3f3f;
      const double pi=3.1416;
      int n,x,ans;
      int main(){
      	scanf("%d",&n);
      	for(int i=1;i<n;i++){
      		scanf("%d",&x);
      		ans^=x;
      	}
      	for(int i=1;i<=n;i++){
      		ans^=i;
      	}
      	printf("%d",ans);
      return 0;
      }
      

      image

      • -1
        @ 2022-2-11 21:07:01
        #include<stdio.h>//节省空间
        int main(){
        	int n;
        	scanf("%d",&n);
        	int ans=n;
        	for(int i=1,x;i<n;i++){
        		scanf("%d",&x);
        		ans=ans^x^i;//^是异或
        	}
        	printf("%d",ans);
        	return 0;
        }
        
        • -1
          @ 2022-1-8 20:13:24
          #include <stdio.h>
          int main()
          {
          	int n,ans;
          	scanf("%d",&n);
          	ans = n;
          	for(int i = 1 , x ; i < n ; i++)
          	{
          		scanf("%d",&x);
          		ans = ans ^x ^ i;
          	}
          	printf("%d\n",ans);
          }
          
          • 1

          信息

          ID
          1138
          时间
          1000ms
          内存
          20MiB
          难度
          7
          标签
          递交数
          463
          已通过
          107
          上传者