資料結構實驗之查詢六:順序查詢(SDUT 3378)
(不知道為啥開個陣列就 TLE 。QAQ)
#include <stdio.h> #include <stdlib.h> #include <string.h> //const int maxn = 100005; // //int a[maxn]; int main() { int n,k,ans,x; while(~scanf("%d%d",&n,&k)) { ans = -1; for(int i = 1; i <= n; i ++) { scanf("%d",&x); if(x == k) { ans = i; } } if(ans == -1) printf("No\n"); else printf("%d %d\n",ans,n - ans + 1); } return 0; }
相關推薦
資料結構實驗之排序七:選課名單 (SDUT 3404)
#include <stdio.h> #include <string.h> #include <stdlib.h> struct node { char data[15]; struct node *next; //存放名字 }; st
資料結構實驗之排序六:希爾排序 (SDUT 3403)
其實,感覺好像增量不同的冒泡,希爾排序概念以後補上。 #include <bits/stdc++.h> using namespace std; int a[10005]; int b[10005]; void shsort(int dk, int n, int a[])
SDUT3403資料結構實驗之排序六:希爾排序
一個較難的排序,但是由於程式碼比較簡潔,理解起來也相對容易 若資料基本有序且記錄較少時, 直接插入排序的效率是非常好的,希爾排序就是針對一組基本有序的少量資料記錄進行排序的高效演算法。我們的任務是對於給定的資料進行希爾排序,其中增量dk=n/(2^k)(k=1,2,3……) 題目要求我們用增
資料結構實驗之排序七:選課名單(裡面包含了新思想!!!!好神奇)
Attention: 如果struct node 裡的陣列開的太大,會導致MLE!!! 資料結構實驗之排序七:選課名單 Time Limit: 1000 ms Memory Limit: 65536 KiB Submit Statistic
資料結構實驗之棧四:括號匹配(棧的運用)
#include <stdio.h> #include <stdlib.h> #include <string.h> int main() { int i,j,n,l; char s[150],p[150]; while(gets(s)!=NULL)
資料結構實驗之查詢六:順序查詢(SDUT 3378)
(不知道為啥開個陣列就 TLE 。QAQ) #include <stdio.h> #include <stdlib.h> #include <string.h> //const int maxn = 100005; // //int a[ma
SDUT-3378_資料結構實驗之查詢六:順序查詢
資料結構實驗之查詢六:順序查詢 Time Limit: 1000 ms Memory Limit: 65536 KiB Problem Description 在一個給定的無序序列裡,查詢與給定關鍵字相同的元素,若存在則輸出找到的元素在序列中的位序和需要進行的比較次數,不存在則輸出"No",序列位序從1
C語言 資料結構排序與查詢 資料結構實驗之排序三:bucket sort
資料結構實驗之排序三:bucket sort Time Limit: 250MS Memory Limit: 65536KB Submit Statistic Problem Description 根據人口普查結果,知道目前淄博市大約500萬人口,你的
SDUT 3403 數據結構實驗之排序六:希爾排序
include 輸入 header 有序 sample 正整數 結果 少量數據 算法 數據結構實驗之排序六:希爾排序 Time Limit: 1000 ms Memory Limit: 65536 KiB Problem Description 我們已經學習
資料結構實驗之陣列三:快速轉置(std::stable_sort函式)
資料結構實驗之陣列三:快速轉置 Time Limit: 1000 ms Memory Limit: 65536 KiB Submit Statistic Discuss Problem Description 轉置
SDUTOJ3311資料結構實驗之串三:KMP應用
資料結構實驗之串三:KMP應用 (PS:這題巨坑 嗚嗚嗚。。) https://acm.sdut.edu.cn/onlinejudge2/index.php/Home/Contest/contestproblem/cid/2710/pid/3311 Time Limit:&nbs
資料結構實驗之排序八:快速排序
資料結構實驗之排序八:快速排序 Time Limit: 1000 ms Memory Limit: 65536 KiB Submit Statistic Discuss Problem Description 給定N(N≤10^5)個
資料結構實驗之排序二:交換排序__快排、冒泡、選擇
Problem Description 氣泡排序和快速排序都是基於"交換"進行的排序方法,你的任務是對題目給定的N個(長整型範圍內的)整數從小到大排序,輸出用冒泡和快排對這N個數排序分別需要進行的資料交換次數。 Input 連續多組輸入資料,每組資料第一行給出正整數N(N ≤ 10^
資料結構實驗之排序一:一趟快排__Sort
Problem Description 給定N個長整型範圍內的整數,要求輸出以給定資料中第一個數為樞軸進行一趟快速排序之後的結果。 Input 連續輸入多組資料,每組輸入資料第一行給出正整數N(N < = 10^5),隨後給出N個長整型範圍內的整數,數字間以空格分隔。 Ou
資料結構實驗之串一:KMP簡單應用
Problem Description 給定兩個字串string1和string2,判斷string2是否為string1的子串。 Input 輸入包含多組資料,每組測試資料包含兩行,第一行代表string1(長度小於1000000),第二行代表string2(長度小
資料結構實驗之陣列一:矩陣轉置
陣列——矩陣的轉置 給定一個m*n的矩陣(m,n<=100),求該矩陣的轉置矩陣並輸出。 Input 輸入包含多組測試資料,每組測試資料格式如下: 第一行包含兩個數m,n 以下m行,每行n個數,分別代表矩陣內的元素。 (保證矩陣內的數字在int範圍之內)
資料結構實驗之串三:KMP應用
Problem Description 有n個小朋友,每個小朋友手裡有一些糖塊,現在這些小朋友排成一排,編號是由1到n。現在給出m個數,能不能唯一的確定一對值l和r(l <= r),使得這m個數剛好是第l個小朋友到第r個小朋友手裡的糖塊數? Input 首先輸入一
資料結構實驗之排序四:尋找大富翁(SDUT 3401)
#include <stdio.h> #include <stdlib.h> #include <string.h> void Swap(int a[], int i, int j) // 交換函式 { int t = a[i]; a[i]
資料結構實驗之排序五:歸併求逆序數(SDUT 3402)
歸併排序詳解(戳我)。 以下是搬了別人的。 #include<stdio.h> #include<stdlib.h> long long sum = 0; int a[100005]; int temp[100005]; void Merge(int s1
資料結構實驗之排序二:交換排序 (SDUT 3399)
#include <iostream> #include <bits/stdc++.h> using namespace std; typedef long long ll; //int sum = 0; int a[100004]; //題目是長整型,不過這裡 i